1

I need to click on one element in a page, but the page gets refreshed every 1-2s (ajax call). Browser used is firefox.

Code:

ele = WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH, ".//*[@id='dojox_grid__View_1']/div/div/div/div/table/tbody/tr/td[1]/div")))
print ele
ele.click()

Error:

mouseOnover.click()
  File "/usr/lib/python2.6/site-packages/selenium-2.53.1-py2.6.egg/selenium/webdriver/remote/webelement.py", line 74, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/usr/lib/python2.6/site-packages/selenium-2.53.1-py2.6.egg/selenium/webdriver/remote/webelement.py", line 457, in _execute
    return self._parent.execute(command, params)
  File "/usr/lib/python2.6/site-packages/selenium-2.53.1-py2.6.egg/selenium/webdriver/remote/webdriver.py", line 233, in execute
    self.error_handler.check_response(response)
  File "/usr/lib/python2.6/site-packages/selenium-2.53.1-py2.6.egg/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Element is not clickable at point (267, 162.5). Other element would receive the click: <div style="width: 1360px; height: 621px;" id="dojox_grid_enhanced_plugins_Dialog_1_underlay" class="dijitDialogUnderlay dojoxGridFDTitlePane_underlay" tabindex="-1" data-dojo-attach-point="node"></div>

How to overcome this problem.

1 Answer 1

2

If the page get's refreshed every two seconds, this result isn't all together surprising. You are waiting upto 10 seconds to get the element but by that time the page would have refreshed several times and made the objects you are holding stale. Stale elements cannot be clicked on. My suggestion is to wait for the body element and quickly grab the element of interest.

 wait = WebDriverWait(driver, 1)
 body = wait.until(EC.element_to_be_clickable((By.TAG,'body')))
 ele = wait.until(EC.element_to_be_clickable((By.XPATH, ".//*[@id='dojox_grid__View_1']/div/div/div/div/table/tbody/tr/td[1]/div")))
 print ele
 ele.click()

Note 1: You are using xpath to select the element. This is slow. Normally it wouldn't matter but in your case you are running against the clock. Try to get by id instead. If the element in question doesn't have an id add one!

Note 2: After all this if you still find that the element is not clickable, that's because some other element is covering it. The overlap maybe by a transparent background so you might not notice.

Taking a closer look at your error message it shows that a width: 1360px; height: 621px; element is getting in the way. At this stage you seem to have a n error in your CSS. The simplest thing to do would be to hide this offending element by changing it's CSS possible via selenium execute javascript feature

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

3 Comments

I throws an error, File "/usr/lib/python2.6/site-packages/selenium-2.53.1-py2.6.egg/selenium/webdriver/support/expected_conditions.py", line 91, in _element_if_visible return element if element.is_displayed() == visibility else False AttributeError: 'tuple' object has no attribute 'is_displayed'
still element is not clickable at point (220, 163). Other element would receive the click error is seen
Glad to have helped.

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.