0

I'm trying to click on an option in a select menu via:

driver.implicitly_wait(30)
driver.find_element_by_xpath("//select[option/@value='today']").click()

but it doesn't work (prints None to the terminal)

the html looks like:

<select tabindex="0" class="itc_listBox mid"><option value="oneDay">1 Day</option><option value="sevenDays">7 Days</option><option value="fourteenDays">14 Days</option><option value="oneMonth">1 Month</option><option value="sixMonth">6 Months</option><option value="oneYear">1 Year</option><option value="" disabled="disabled">————————</option><option value="today">Today</option><option value="yesterday">Yesterday</option><option value="weekToDate">Week-to-Date</option><option value="last7Days">Last 7 Days</option><option value="lastWeek">Last Week</option><option value="monthToDate">Month-to-Date</option><option value="last30Days">Last 30 Days</option><option value="customDateRange">Custom </option></select>

I'm using the Firefox webdriver and I think the html is being generated by js

teegs
  • 25
  • 1
  • 3

2 Answers2

3

Your XPath looks wrong. Try:

"//select/option[@value='today']"
prestomanifesto
  • 12,090
  • 5
  • 32
  • 50
0
Select day = new Select(driver.findElement(By.cssSelector(".itc_listBox")));
day.selectByVisibleText("Today");

or

day.selectByValue("today")

You can try either of the above.

AlexVogel
  • 10,531
  • 10
  • 61
  • 71
user3487861
  • 340
  • 2
  • 2