2

I have below code -

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox()
driver.get("url")
username = driver.find_element_by_id("LoginID")
pwd = driver.find_element_by_id("Password")
username.send_keys('usrnme')
pwd.send_keys('pswd')
Login = driver.find_element_by_id("Button2")
Login.click()
Create = driver.find_element_by_xpath("//*[@title='Create Incident']")
Create.click()

Whenever I am running this code in script or in batch I am getting below error -

Traceback (most recent call last):
  File "P:\Selenium\helpline1.py", line 15, in <module>
    Create.click()
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webelement.py", line 628, in _execute
    return self._parent.execute(command, params)
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "P:\Selenium\python-3.5.1\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 237, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.ElementClickInterceptedException: Message: Element <a id="anc" class="RedirectTab" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("anc", "", true, "", "", false, true))"> is not clickable at point (207.1666717529297,25) because another element <div id="overley" class="over_ley"> obscures it

Login to the site happens perfectly but after that this error in clicking an element (that is the next line of code).

Also when I am running this code line by line manually in Python IDLE or Python CLI it runs without any error. Issue just in script/batch mode in IDLE or Python CLI

Thanks to suggest.

iamsmith41
  • 273
  • 3
  • 9
  • 16
  • Possible duplicate of [Selenium Web Driver & Java. Element is not clickable at point (36, 72). Other element would receive the click:](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el) – undetected Selenium Jan 25 '18 at 10:52
  • 1
    You need to add wait before click event – Ankur Singh Jan 25 '18 at 10:55

2 Answers2

6

If overlay displayed while you're trying to perform a click, you might need to wait until overlay is closed:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


...
Create = driver.find_element_by_xpath("//*[@title='Create Incident']")
WebDriverWait(driver, 10).until_not(EC.visibility_of_element_located((By.ID, "overley")))
Create.click()
Andersson
  • 51,635
  • 17
  • 77
  • 129
2

Try this:

from selenium.webdriver.support import expected_conditions as EC
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

driver = webdriver.Firefox()
wait = WebDriverWait(driver, 10)
driver.get("url")
username = driver.find_element_by_id("LoginID")
pwd = driver.find_element_by_id("Password")
username.send_keys('usrnme')
pwd.send_keys('pswd')
Login = driver.find_element_by_id("Button2")
Login.click()
element = wait.until(EC.element_to_be_clickable((By.XPath, "//*[@title='Create Incident']")))
Create = driver.find_element_by_xpath("//*[@title='Create Incident']")
Create.click()

By usin a wait, you will give time to browser to load de button, BEFORE try to performe the click, that will happen when the element is prepared.