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 JS
I found handy something like:
wait.until(
ExpectedConditions
.presenceOfNestedElementsLocatedBy(By.id(<selectioNId>), By.tagName("option"))
)
You can use "WaitForSelectOption" command where your value can be direct label like label=1-saving Account target will have the object id
I made the following function in C# that returns the select when is populated.
You have to pass a By to find the element and you a specific time to wait for it to be filled:
public static SelectElement FindSelectElementWhenPopulated(this IWebDriver driver, By by, int delayInSeconds)
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(delayInSeconds));
return wait.Until<SelectElement>(drv =>
{
SelectElement element = new SelectElement(drv.FindElement(by));
if (element.Options.Count >= 2)
{
return element;
}
return null;
}
);
}
In my case I validate tha the select has more than 2 options, you can change the code so that it validates the quantity that fits your needs.