finding xpath for elements in applications built on angularjs -


the application under test built on angular because of xpaths failing locate element . using selenium web diver automating tests , google chrome browser.

can kindly specify how break down angularjs components basic html elements while creating xpath or other way can adapt find exact element on page.

any link or path or tips follow.

i have searched lot no luck till now.

starting covering general concerns.

when testing angularjs applications, timing issues common - partially why have tools protractor built test angularjs applications. makes unique works in sync angular, knowing when ready interacted with. provide angularjs specific locators makes locating elements easier, samples:

element.all(by.repeater("item in items")); element(by.binding("mybinding")); element(by.model("mymodel")); 

if can, should consider switching protractor - test flow natural - no explicit waits, lot of convenient syntactic sugar , more element-locating options.

if not, can still use angular-specific attributes locate elements, examples:

driver.findelements(by.xpath("//*[@ng-repeat='item in items']")); driver.findelement(by.xpath("//*[@ng-binding='mybinding']")); driver.findelement(by.xpath("//*[@ng-model='mymodel']")); 

though, usual, should prefer use ids, classes , other "data-oriented" attributes.

things can go wrong above sample expressions - imagine web developers add "tracking" repeater, or rename ng-repeater data-ng-repeater.

as side note, using angular specific things ng-* attributes in tests, make test codebase tight specific technology used build application under test. not bad thing should keep in mind.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -