One of the tasks of the company RTL-Service, which develops local positioning systems with high accuracy and provides voice communication over an encrypted channel, is to develop a web client:

In connection with the constant development of the web client (optimization, the emergence of additional functions), the task of minimizing the time spent by the tester and the developer of autotests is particularly relevant. The following is an experience of accelerating the development of UI tests by applying for this Selenide and Python employees of our testing department.
')
Selenide seems to have obvious advantages. First, Selenide is the top software level of Selenium Webdriver, allowing to reduce the time for performing standard Selenium operations and, as a result, speed up writing and support of autotests. Secondly, in our case, Selenium tests were written in Java, which led to the choice of a software platform in the same language.
Among other things, Selenide “out of the box” has a number of such useful features as: autoscreens of failed tests, the ability to load into one line or download a file, quick deployment of the test environment (one line open (“http://rtlservice.com/”)) and many others. At the end of the test, an error will appear in the console like the following:
Element should not be exist {By.name: infoEdit} Element: '<div class="icon btn size-2" name="infoEdit" title=""></div>' Screenshot: file:
and full stack track as usual.
In this case, 1458565041545.0.png and there is a screenshot of the browser window where you can see the exact location of the problem.
Since the main browser for our system is Chrome, where the main scripts are tested on Debian 7, in the first stage you may encounter the problem of initializing the web driver. After the test was performed on different systems by our employees, it was concluded that this problem relates more to the operating system than to the platform itself. To eliminate this problem, an instance of RemoteWebDriver was created in the initialization code using chromedriver and passed via the static setWebDriver method to Selenide. To implement this method, the following sequence of actions was observed:
1. Installing chromedriver.
2. Running chromedriver is not under sudo. By default, it starts at 127.0.0.1:9515.
3. Creating a driver through the
before annotation:
@Before public void openBrowser () throws Exception { driver = new RemoteWebDriver(new URL("http://127.0.0.1:9515"), DesiredCapabilities.chrome()); WebDriverRunner.setWebDriver(driver); driver.manage().window().maximize();
In addition, another significant advantage of using Selenide is the availability of advanced methods for managing the elements themselves in the DOM. If, for example, in Selenium everything comes down to the click () method with checking for an isSelected () element, then Selenide has the ability to select checkboxes / radio buttons or lists.
For example, in our project OpenLayers is used, so for more convenient work with layers (enable / disable) in Selenide you can make a rather laconic design that will remove the selection from all checkboxes:
for (SelenideElement checkBox : $$(By.tagName("input")).filterBy(Condition.hasAttribute("type", "checkbox"))) { checkBox.setSelected(false); }

An equally important point is the use of "smart expectations". “Smart expectations” is a simpler code for reading without WebDriverWait cluttering up or waiting through Thread.sleep with the timing of the appearance of the element on the eye.
In the case of Selenide, it suffices to write:
$(By.id("select-map-div")).waitUntil(Condition.visible, 5000);
where 5000 is the time in milliseconds during which Selenide will wait for the element to appear.
To the note: if you are sure that the element will appear in the interval of up to 4 seconds, then it is enough to use only the method of should. In this case, Selenide will wait 4 seconds before an error is displayed. Of course, this time can be changed in the configuration.
Thus, on such nuances, Selenide allows you to save a lot of time both on writing tests and on their support, at least when using the more obvious construction of should compared to assertions.
You can learn more about the features of Selenide in the article of the developer of this tool (
https://habrahabr.ru/post/274071/ ).
The second important detail in accelerating the development of tests is the use of Python, which adds flexibility to tests and is used to quickly develop additional tools that make life easier for testers.
Python enhances test flexibility with its interpretability, which allows you to work with a periodically changing API. That is, simply by invoking a Python script from Java, you can always get actual data without making changes to the test code, be it events, location, maps, or something else.
In addition, it is possible to sample from the database to obtain the necessary data in the process of updating the structure of this database from version to version. In our case, this is used to obtain device numbers and further calls to them from the tests themselves.
This item also implies the ability to use both virtual and real devices in the testing process, replacing the sample from the database with an array of MAC addresses of the necessary devices and running the test (sometimes this can also reveal problems in the device firmware).
It is noteworthy that Python also writes scripts to various internal programs for manual testing, providing a more interactive shell. Undoubtedly, bash can be used for this, but, subjectively, Python has a lower entry threshold and, if there are any problems, the script will be easier to fix on it.
Thus, on the one hand, with the use of Selenide, we were able to increase the speed of developing autotests by 30% and greatly facilitate their support, and, on the other, with the help of Python, we managed to achieve flexibility of tests in a dynamically changing system.
Authors: Nikolay Fedorov, Nikolay Smirnov