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?
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.
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.
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 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.
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
waitForElementPresent
css=#myselect option[value=123]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With