A
A
Alexander Vasilenko2016-12-09 17:59:46
JavaScript
Alexander Vasilenko, 2016-12-09 17:59:46

What is the easiest way to define locators for testing an AngularJS application using Protractor?

In general, there is experience in testing on Selenium + Java, but the task is to test on Selenium + JS + Protractor.
The web application is assembled by the bundle file, as far as I understand, there is very little information in the markup of the html file (if we take it from source). The file is just huge, it's hard to figure it out quickly.
I would like to have an idea about purely Angular locators. Is it possible to describe web elements based on information from the bundle.js file? Or is it necessary to take css, xpath, names from already formed pages? how to avoid falling tests, in this case. if during the initialization of elements on the page, some elements remain undefined and the tests fail (in fact, because of this, they did not use Java + Selenium, there is very little control over the Angular processes themselves during testing).
Regarding the last point, there is a method browser.waitForAngular(); but how much can it be trusted to wait for elements on the page to be initialized?
If anything, thank you for your patience, AngularJS is a very new topic for me, I'm still trying to figure out what's going on. So, if my question seemed stupid, I apologize.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
X
xtozna, 2016-12-17
@xtozna

https://www.npmjs.com/package/elementor - maybe this will help you.

T
Talik, 2017-01-10
@Talik0507

(actually, because of this, they did not begin to use Java + Selenium, there is very little control over the Angular processes themselves during testing).
Well, it's a moot point... You'll have to play tricks, but there's plenty of control.
Regarding the search for locators. It is probably possible to search for locators by the content pattern of the original page. But as far as I've seen, Predactor is a framework to make it easier to work with elements... There, of course, a number of methods have been added to make searching easier (but not much). Moreover, if some elements are formed dynamically, depending on the conditions, then it is easier to write tests based on the locators of the final pages of the project.
About "browser.waitForAngular();" is just an implemented wait waiting for certain elements to be initialized by Angular. If some other aspects slow down, this method will no longer work ... therefore, you can trust. but without shamanism all the same, in certain cases it is impossible to do.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question