1

I have not been able to find a working example of how to select a menu choice inside this particular form.

I have tried a few of the examples here on SOF and have had no success. Below is my most current attempt.

Form Code on Webpage:

<select name="searchTime" id="diningAvailabilityForm-searchTime" class="searchTime inputElement" min="06:30:00" max="22:30:00" allday="00:00:00 23:30:00">
<option value="80000712" label="Breakfast" selected="selected">Breakfast</option>
<option value="80000713" label="Brunch">Brunch</option>
<option value="80000717" label="Lunch">Lunch</option>
<option value="80000714" label="Dinner">Dinner</option>
<option value="06:30" label="6:30 AM">6:30 AM</option>
<option value="07:00" label="7:00 AM">7:00 AM</option>

Existing Non-working Code

el = driver.find_element_by_id('diningAvailabilityForm-searchTime')
for option in el.find_elements_by_tag_name('option'):
    if option.text == '06:30 AM':
        option.click() # select() in earlier versions of webdriver
        break
  • Could the page perhaps be using bootstrap? The page I was working on recently did so and I had to click on the elements that bootstrap added instead of on the standard select/option elements. –  Oct 28 '19 at 01:21
  • Is there a plug-in that you used to be able to check easily? – Mark Sanchez Oct 28 '19 at 01:51
  • Nah. I had to go look at the generated HTML in DevTools to see what elements I had to click. –  Oct 28 '19 at 02:23
  • E.g., on this one page, bootstrap-chosen added a div with class=chosen-container containing an unordered list (ul/li) that I had to click on instead of on the select/option elements. –  Oct 28 '19 at 02:29
  • Or perhaps I just did not read your code and projected my difficulties on to yours. Check out this [SO answer](https://stackoverflow.com/a/28613320/5386938) using the [Select class](https://selenium-python.readthedocs.io/api.html#module-selenium.webdriver.support.select) –  Oct 28 '19 at 02:33

0 Answers0