1

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)

1 Answer 1

1

From the error it looks like.

  1. The element is loaded into the DOM, but the position is not fixed on the UI yet.
  2. There can be some other divs not getting loaded completely.

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.