Issue
In order to output my already selected option I coded:
Select(driver.find_elements(By.XPATH,'path_to_select/select/option'))
selected_option = select.first_selected_option
print(selected_option)
Error Message:
raise UnexpectedTagNameException( selenium.common.exceptions.UnexpectedTagNameException: Message: Select only works on elements, not on
Solution
Because you are selecting a list of elements. So you can use driver.find_element()
instead of driver.find_elements() to select a single element.
select = Select(driver.find_element(By.XPATH,'path_to_select/select/option'))
selected_option = select.first_selected_option
print(selected_option)
Answered By - F.Hoque
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.