I'm trying to select an item from a bootstrap dropdown with selenium. I can click the dropdown itself and get the options shown, but I can't click any option.
I tried different things but I'm getting:
TypeError: 'str' object is not callable
This is the line that I need to fix:
option = driver.find_element(By.XPATH("//li[text()='Element'"))
option.click()
I also tried using this code with the same error:
options = driver.find_elements(By.XPATH("//ul[contains(@class,'a-list')]/a"))
for option in options:
optionText = option.text()
if optionText == ('Element'):
option.click()
break
I also tried using these codes with different xpath in case that was the mistake, but keep getting the same error.
I'd appreciate any help. Thanks in advance!