Reputation: 125
I am using python selenium on browser to fill in some form. I was trying to select an element in the drop-down list,
<a href="#" class="dropdown-toggle select" data-toggle="dropdown">0</a>
but if I try to find it by text using this script:
browser.find_element_by_link_text("0").click()
it result an error: "unknown error: Element is not clickable at point (498, 612). Other element would receive the click: ..."
and if try to find it by class name:
browser.find_element_by_class_name("dropdown-toggle").click()
it result in another error: "element not visible"
is there any way I can click onto that drop-down list? Thanks very much.
Upvotes: 4
Views: 14881
Reputation: 125
Thanks for the feedback, I've found the problem which was due to the new script being loaded by javascript as triggered by some clicks. I've created the following code to capture the exception and retrying until the element is ready:
while True:
try:
time.sleep(1)
browser.find_element_by_xpath("//div[@class='tckt']/a").click()
print("found")
break
except ElementNotVisibleException:
print("notvisible")
except WebDriverException:
print("clickduplicate")
I read it on articles says this happened a lot on radio button for Chrome webdriver, hope this helps.
Upvotes: 0
Reputation: 1763
Try to find it by Xpath searching for partial class and text at the same time:
browser.find_element_by_xpath(//a[contains(@class, 'dropdown-toggle select') and contains(text(), '0')]).click();
Upvotes: 1
Reputation: 1029
I had a similar problem. You can execute a script to change the visibility of that element once you find it and then click it.
driver.execute_script("arguments[0].style.visibility = 'visible';",myElement)
myElement.click()
Upvotes: 2
Reputation: 111
Firstly click the parent element by finding it, using it's xpath
->find the element you want to click within the parent element like the way you did. i.e
browser.find_element_by_link_text("0").click()
Hope this 2 steps will work for you. Otherwise please post the url with the code you've tried-It'll be easy to find out the issue.
Upvotes: -1
Reputation: 695
you should get the element by xpath and then press it.
browser.find_element_by_xpath(xpath).
read here how to get the xpath: http://www.wikihow.com/Find-XPath-Using-Firebug
Upvotes: 0