Reputation: 9
I can't click a button containing JavaScript:
<div style="width:100%; float:left;"><div class="btn btn-search" onclick="javascript: search(); " style="cursor:pointer;width:100%" align="center">Ara</div></div>
I found the element, but the code below doesn't click:
browser.find_element_by_xpath('//div[@class="btn btn-search"]').click()
or
browser.find_element_by_xpath('//div[@onclick="javascript:"]').click()
This message is returned:
Message: unknown error: Element is not clickable at point (1153, 417)
Upvotes: 1
Views: 122
Reputation: 101
From the error it looks like.
Possible solutions:
Use WebdriverWait with click()
from selenium.webdriver.support.ui import WebDriverWait
wait = WebDriverWait(browser, 30)
element = wait.until(EC.visibility_of_element_located((By.XPATH, //div[@class="btn btn-search"]')))
element.click()
Use WebdriverWait with Javascript execution
from selenium.webdriver.support.ui import WebDriverWait
wait = WebDriverWait(browser, 30)
element = wait.until(EC.visibility_of_element_located((By.XPATH, '//div[@class="btn btn-search"]')))
browser.execute_script("arguments[0].click();", element)
Further Reference: https://www.seleniumeasy.com/selenium-tutorials/element-is-not-clickable-at-point-selenium-webdriver-exception
Also when you frame question please share,
Full error and the code (especially the line before you are trying to click).
Other details such as browser (from error looks like Chrome browser as it is indicating point location).
This will help the community understand your issue more clearly.
Upvotes: 1