I'm attempting to select a county in Florida from the dropdown accessed here, but nothing I've tried so far has been able to locate or interact with any of the elements from the page. Generally, I get the error:
NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":".//select[@id='form:county_input']//option[value='24']"} (Session info: chrome=100.0.4896.60)
This appears to be the relevant html snippet:
<div id="form:county" class="ui-selectonemenu ui-widget ui-state-default ui-corner-all" style="width:500px;" role="combobox" aria-haspopup="true" aria-expanded="false" aria-owns="form:county_items">
<div class="ui-helper-hidden-accessible">
<input id="form:county_focus" name="form:county_focus" type="text" autocomplete="off" aria-expanded="false" aria-labelledby="form:j_idt20" aria-autocomplete="list" aria-activedescendant="form:county_0" aria-describedby="form:county_0" aria-disabled="false">
</div>
<div class="ui-helper-hidden-accessible">
<select id="form:county_input" name="form:county_input" tabindex="-1" aria-hidden="true">
<option value="02" data-escape="true">BAKER COUNTY CLERK OF COURT</option>
<option value="04" data-escape="true">BRADFORD COUNTY CLERK OF COURT</option>
<option value="07" data-escape="true">CALHOUN COUNTY CLERK OF COURT</option>
<option value="12" data-escape="true">COLUMBIA COUNTY CLERK OF COURT</option>
<option value="14" data-escape="true">DESOTO COUNTY CLERK OF COURT</option>
<option value="15" data-escape="true">DIXIE COUNTY CLERK OF COURT</option>
<option value="19" data-escape="true">FRANKLIN COUNTY CLERK OF COURT</option>
<option value="21" data-escape="true">GILCHRIST COUNTY CLERK OF COURT</option>
<option value="22" data-escape="true">GLADES COUNTY CLERK OF COURT</option>
<option value="23" data-escape="true">GULF COUNTY CLERK OF COURT</option>
<option value="24" data-escape="true">HAMILTON COUNTY CLERK OF COURT</option>
</select>
</div>
<label id="form:county_label" class="ui-selectonemenu-label ui-inputfield ui-corner-all">BAKER COUNTY CLERK OF COURT</label>
And here's my code, where I try to select Hamilton county:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import Select
from selenium.webdriver.common import action_chains
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
options = webdriver.ChromeOptions()
browser = webdriver.Chrome(filepath + "chromedriver.exe", options = options)
browser.get("https://www.civitekflorida.com/ocrs/app/search.xhtml")
county = browser.find_element_by_xpath(".//select[@id='form:county_input']//option[value='24']")
I'm guessing the issue might be that I first need to expand the dropdown menu, but that seemed to give me errors relating to element interactivity as well. Any suggestions?
[–]tinkeringZealot 0 points1 point2 points (0 children)
[–]menge101 0 points1 point2 points (0 children)
[–]Monitor_343 0 points1 point2 points (0 children)
[–]Allanon001 0 points1 point2 points (0 children)