java - How to retrieve AngularJS generated content in li from Selenium and JUnit? -


i writing integration test play! framework, junit , selenium. client side web has angularjs fullfill page content. want test content cannot how it. here sample code:

html view:

... <ul name="quequeentitylist">    <li class="list-group-item" ng-click="turnclick($index)" ng-repeat="turn in turns"> {{turn.value}}</li> </ul> ... 

junit selenium test:

@test public void logintocontrolpaneltest() {     running(testserver(9000, fakeapplication()),             htmlunit,             new callback<testbrowser>()             {                 public void invoke(testbrowser browser)                  {                               browser.goto("http://localhost:9000/panel");                     browser.await();                       system.out.println(browser.find("ul[name='queueentitylist'] > li"));                 }             });         } 

with simple test ul want navigate through lis , see generated content, how can it?

by default selenium actions without waiting , tries execute right after previous action. in example, find() executed right after page loaded. however, when using angular or other asynchronous (like ajax calls) moment when page loaded not meet rendered , ajax request have finished.

thus must use wait , provide selenium condition, should wait for, until continues test execution. in case ie. when number of

  • elemets greater one, behaves ajax request takes moment until loaded.

    see also:


  • Comments

    Popular posts from this blog

    android - MPAndroidChart - How to add Annotations or images to the chart -

    javascript - Add class to another page attribute using URL id - Jquery -

    firefox - Where is 'webgl.osmesalib' parameter? -