So here is what's happening:
When you click on <div id="countSelect"></div>
JavaScript's show_countSelector()
is executed and the values are appended to the table. Those "select options" are actually "table rows".
So your steps are:
1) If there are no rows with class selec_option
under div
with id countSelect
, then you need to click on that div
first.
2) After that you click on the particular row.
So I'll try to show the Java code (however, I use Python for Selenium):
WebElement selectorElement = driver.find(By.xpath('//*[@id="countSelect"]')));
WebElement elementOfInterest;
try {
//trying to get the "select option"
elementOfInterest = selectorElement.findElement(By.xpath('//*[contains(@class,"selec_option")]/td[@text()="50"]'))
} catch (NoSuchElementException e) {
//so options are not visible, meaning we need to click first
selectorElement.click()
//good idea would be to put "wait for element" here
elementOfInterest = selectorElement.findElement(By.xpath('//*[contains(@class,"selec_option")]/td[@text()="50"]'))
}
//this would select the option
elementOfInterest.click()
Something like this. :)