I have below html code, all I want to click on the dropdown and select the first value.How can I achieve this.I am having issues when selecting the values from dropdown but was able to click the dropdown
<div id= "location-select-list" class="mb-list" role="role0">
<mb-option id='1' class='classname' role='rolename' data-auto-id="dt1" aria-disabled="False" 1 </mb-option>
<mb-option id='2' class='classname' role='rolename' data-auto-id="dt2"aria-disabled="False" 2 </mb-option>
I have tried this but not working.
#click on the dropdown--working
WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH,
xpath_0))).click()
#selecting 1st value from the dropdown value list--not working
xpath = "//div[@id='location-select-list']//mb-option[@data-auto-id='dt1']"
WebDriverWait(driver, 5).until(EC.visibility_of_element_located((By.XPATH,
xpath))).click()
//div[@id='location-select-list']//mb-option[@data-auto-id='dt1']is the unique locator 2) Have you tried to usevisibility_of_element_locatedinstead ofelement_to_be_clickableespecially for the second command? 3)Can you share a link to that page?visibility_of_element_locatedusingselect. but it's throwing error since the the dropdown is coded insidediv.And yes the xpath is uniqueselectn your HTML. So, if it is not there, why to use it?selectselect"..