Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium: How to wait for options in a select to be populated?

I am using Selenium for the first time and am overwhelmed by the options. I am using the IDE in Firefox.

When my page loads, it subsequently fetches values via an JSONP request, with which it populates options in a select.

How do I get Selenium to wait for a certain option in the select to be present before proceeding?

like image 519
mydoghasworms Avatar asked Jul 04 '11 06:07

mydoghasworms


People also ask

How do you wait for a element to load in Selenium?

We can wait until an element is present in Selenium webdriver. This can be done with the help of synchronization concept. We have an explicit wait condition where we can pause or wait for an element before proceeding to the next step. The explicit wait waits for a specific amount of time before throwing an exception.

What should be used in Selenium to wait for some conditions?

The Explicit Wait in Selenium is used to tell the Web Driver to wait for certain conditions (Expected Conditions) or maximum time exceeded before throwing “ElementNotVisibleException” exception. It is an intelligent kind of wait, but it can be applied only for specified elements.

How do you use implicitly wait using Selenium to wait until full page load?

Using Implicit WaitThe Implicit Wait tells WebDriver to wait a specific amount of time (say, 30 seconds) before proceeding with the next step. If the tester knows how much time the page and element will take to load, they should use Implicit Wait.

What is dynamic wait in Selenium?

What are dynamic waits? Consider a situation where you have given a TimeOut value of 20 seconds. If the element is loaded in 5 seconds, then rest 15 seconds will be ignored. It won't wait until the TimeOut value is completed, i.e 20 seconds.


1 Answers

I used waitForElementPresent with a css target.

Example: To wait for

<select id="myselect"></select>

to be populated with

<option value="123">One-two-three</option>

use

  • Command: waitForElementPresent
  • Target: css=#myselect option[value=123]
  • Value: (leave it empty)
like image 189
user1460043 Avatar answered Sep 23 '22 15:09

user1460043