I am doing a Python programing via Selenium using Chrome Driver, aiming for saving efforts for duplicated operations on the web, e.g. changing status for each of many sub-tasks.
Everything is fine until the Python and Selenium logs in and trying to select the Status drop-down list, which is the element on the dynamic page generated by possibly Javascript. Note I need to manually log in and change status for some tickets and now trying to automate it.
The page is multiple hierarchy, and with similar structures for multiple select.
I did a screenshot for HTML code partial and page look.
I tried using the following
1)
dropdownSelect = driver.find_element(By.XPATH, "//p[@class='ng-star-inserted/select[@_ngcontent-c16='']")
dropdown =Select(dropdownSelect)
print('Options are: ')
for opt in dropdown.options:
print(opt.text)`
Result 1: Unable to locate an element with the xpath expression**
2)
dropdownSelect = driver.find_element(By.XPATH, "//select[1]")
dropdown =Select(dropdownSelect)
print('Options are: ')
for opt in dropdown.options:
print(opt.text)`
Result 2: empty option (no option)**
3)
dropdownSelect = driver.find_element(By.XPATH, "//select[4]")
dropdown =Select(dropdownSelect)
print('Options are: ')
for opt in dropdown.options:
print(opt.text)
Result 3: no such element: Unable to locate element
Note I search select[4] because there are multiple select elements in generate HTML page. The one I am locating is the 4th element.
I hope for instruction of effective Selenium code /method to locate the mentioned drop-down list so that I can mimic selecting an item for it.
I thank you in advance.
Mike Lee is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.