RK . N
RK . N

Reputation: 308

How to make Chrome to wait for dynamic li elements to get loaded in Ul with Watir webdriver

Here "li" elements would display dynamically based on search results in page . so how could ask chrome browser to wait until all li elements get loaded before clicking on save

It is working fine in firefox , but i am getting this issue on chrome

<ul class="profile-section-list search-results-list">

all 'li' would get loaded dynamically


</ul>

Upvotes: 0

Views: 176

Answers (1)

Justin Ko
Justin Ko

Reputation: 46836

If you expect a certain number to appear, you can wait for the last one to appear.

One option is to wait until the ul element has at least 20 li elements:

browser.wait_until do
  browser.ul(class: 'search-results-list').lis.length >= 20
end

Another option is to wait until the 20th li becomes present (note that this is a 0-based index):

browser.ul(class: 'search-results-list').li(index: 19).wait_until_present

Upvotes: 1

Related Questions