25

I'm trying to click a button on top of the page.I'm using CSS selector and it works perfectly fine when I run it in my local eclipse.But when I try to run it on Jenkins server on my local machine it fails, saying element not clickable. When I saw the screenshot of failed test on Jenkins I see that the header is overlapping the button that I want to click. I have tried almost everything using XPath,CSS,move to element,move mouse. But still can't fix it, Someone please help.

I'm tring to click on add buttoun

org.openqa.selenium.WebDriverException: Element is not clickable at point (775.25, 10.166671752929688). Other element would receive the click: <div class="globalHeader-UtilTop"></div>
Command duration or timeout: 69 milliseconds
Build info: version: '2.53.0', revision: '35ae25b1534ae328c771e0856c93e187490ca824', time: '2016-03-15 10:43:46'
System info: host', ip: '', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.7.0_80'

<div class="Componet-intels**strong text**-Container">
<div class="Componet-intels-Container-Header">
<div class="Componet-intels-Container-Content">
<div class="Componet-intels-Container-Content-Row">
<span class="Componet-intels-Item"> Item # </span>
<span class="Componet-intels-Text-Item">
<span class="Componet-intels-Lable-Quantity"> Qty: </span>
<span class="Componet-intels-Text-Quantity">
<span class="Componet-intels-Button">
**<input class="Componet-intelsButtonIcon" type="button" value="Add">**
</span>
</div>
Samantha
  • 357
  • 2
  • 7
  • 17

4 Answers4

31

Element is not clickable at point (775.25, 10.166671752929688). Other element would receive the click:

It clearly says, the element we want to click is hidden by some other element div in this case, which would receive the click.

I think it is a problem with the UI and the header shouldn't hide the element, but you can try few things :

  1. Maximize the window of the browser from webdriver to see if header still hides the element

    driver.manage().window().maximize() 
    
  2. Use JavaScript to click element

    WebElement element = driver.findElement(By.<locator>);
    JavascriptExecutor executor = (JavascriptExecutor)driver;
    executor.executeScript("arguments[0].click()", element)`
    
serv-inc
  • 35,772
  • 9
  • 166
  • 188
Satish Gupta
  • 1,447
  • 1
  • 12
  • 14
  • 1
    How have you defined the "driver" variable? – nix86 Jun 23 '17 at 14:11
  • @nix86 The code presented in this answer is a pseudo code. The "driver" variable is an instance of an implementation of the WebDriver interface (see https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/WebDriver.html). – Stephan Aug 23 '17 at 08:20
  • in my case hidden by a **transparent** element. If you click at the position where the element is located it would work. Because the other element can handle the click as well. Another case of error message no one needs. – Martin Aug 31 '22 at 11:59
1

use JavascriptExecutor.:-

WebElement element = driver.findElement(By.<locator>);

JavascriptExecutor executor = (JavascriptExecutor)driver;
executor.executeScript("arguments[0].click()", element)
Regolith
  • 2,944
  • 9
  • 33
  • 50
Spike
  • 19
  • 2
0

Im my case, I had to click on a button which would be visible only after a few graphs were loaded and then an ajax image. The below steps helped me to fix the issue:

  1. Identify the xpath/css which disappears after ajax call is complete and explicitly wait for it to be invisible-wait.until(ExpectedConditions.invisibilityOf(element));

  2. One more explicit wait for the button to be clickable-wait.until(ExpectedConditions.elementToBeClickable(element));

  3. Use javascript to click on the button-

    WebElement element = driver.findElement(By.xpath("")); JavascriptExecutor js = (JavascriptExecutor)driver;
    js.executeScript("arguments[0].click()", element);

If still this doesn't work try inserting an implicit wait between step 1 and 2.

Om Sao
  • 7,064
  • 2
  • 47
  • 61
Amit
  • 178
  • 1
  • 6
  • Don't understand the downvote, executeScript works for me when click() and driver.actions().click() didn't work – Harvey Lin Feb 12 '18 at 23:21
0

I got this error while using Robot Framework and Chrome browser for Salesforce automation , It got solved when I used key press event (Press Keys ${locator} RETURN) instead of 'Click Element' or 'Click Button' keyword.

vijay
  • 1