Automating Magento Testing Process. Speeding Up the Search for Elements

Automating Magento Testing Process. Speeding Up the Search for Elements

As we stated in the previous article, in most cases it is impossible to make search in the admin panel using the ID parameter, so instead we have to frequently use the Xpath locators to effectively use the automation. But in this case along with losing the flexibility we also encounter another problem – it significantly increases the time to search and find an element and, therefore, the time to execute tests. This is not so noticeable if you are trying to automate acceptance tests only. But if you need to automate the complete project, the speed of the test execution increases enormously.

A possible solution would be to use the standard method Selenium – аssignId

It temporarily assigns a specified identifier to an element. So later, before reloading the page, you can access this element directly through this identifier, not through the slow and cumbersome Xpath locator.

This method can be useful, for example, when elements are added on the page via аjаx without reloading the page. As seen on the picture below, elements are added via the Add Exception button without reloading the page and the element has a generated Id, which makes us to use the Xpath locator.

Therefore, we need to access the buttons “Delete” and “Add Exception” through the assigned identifier.

Here is an example of a test, which uses such method:

It is also necessary to use the аssignId method in case you expect a page element with a generated Id to appear. This happens due to the fact that cycle is repeatedly searching for one and the same element, thus, before starting the cycle, assign first the identifier to an element via the method аssignId, and then access it directly in the cycle. This is how it looks:

Another time-consuming procedure during the test execution is filling of the multiselect tag.  It is also possible to speed it up using the аssignId method.

These are just some examples of possible assigning an Id to a page element. Use the аssignId method where it is necessary and you’ll see significant advances in your test performance optimization.

Post a new comment

BelVG Newsletter
Subscribe to our mailing list and get interesting stuff and updates to your email inbox.
Email *