12

I have following problem. I run test on Firefox and Chrome. On Firefox test run correctly but on Chrome SauceLabs give a message:

unknown error: Element is not clickable at point (717, 657). Other
element would receive the click: <div class="col-md-9 col-sm-12"
style="margin-top:8px;">...</div> (Session info: chrome=36.0.1985.125)
(Driver info: chromedriver=2.10.267521,platform=Windows NT 6.3 x86_64)

I choose element by unique css selector in both test in the same way:

driver.FindElement(By.CssSelector("button.btn-xs:nth-child(1)")).Click();

Any ideas what is wrong here?

Sowiarz
  • 1,051
  • 2
  • 12
  • 27

8 Answers8

18

I am assuming that you have the correct element you need, ie the XPath is correct. Here are few ways out:

  1. Try to Click on the parent element instead.
  2. Try .Submit() instead of .Click()
  3. Try to execute the JavaScript that will be executed on the OnClick event of the element you are trying to click.

I have used the 3rd way with success all the time.

Another one

  1. Do a .SendKeys(Keys.Enter) on that element (or a Space key)
bit
  • 4,139
  • 1
  • 25
  • 44
  • 1. does not work 2. does not work: no such element: "Element was not in a form, so could not submit." – Sowiarz Sep 19 '14 at 09:27
  • Are you sure that the Element exists in the form, since by 2, you got that message? Anyways try 3 – bit Sep 19 '14 at 09:28
8

Since you've tagged the question as Google-Chrome too - I suppose that this is happening mostly with ChromeDriver. I had the same issues with one of my previous projects (Asp .Net MVC). I found that when some elements are not visible for this Driver if they are not in the screen_visible_area. Please note that they are loaded (HTML, CSS3, JS etc.) properly.

So after a lot of reading and testing, I found that my workaround is simply scroll to the WebElement - so it is in the visible part of the screen. Actually this issue was not for all elements and I didn't find better solution for it.

unknown error: Element is not clickable at point (..., ...) 

Is not descriptive error for this case, because like you I also thought that is Selector-related.

Just to be full answer - I had the same problems with IEDriver too. My implementation was to use the Browser scroll down/up options and just "send the screen" where the problematic element is.

Simple JSExecutor code that you can use:

WebDriver driver = new FirefoxDriver();
JavascriptExecutor jse = (JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(110,350)", "");

or

jse.executeScript("scroll(0, 250);");

or

driver.executeScript("window.scrollBy(110,350)", "");

Other topic-related useful resources are here.

Update

When it comes to the .sendKeys() I also used the browser accessibility features. All you need to do is just count how many TAB clicks your test need in order to get to the targeted web_element. Then just call .click().

Try this simple code:

element.sendKeys(Keys.TAB);

or

element.sendKeys("\t")

or

Actions builder = new Actions(driver);
builder.keyDown(Keys.TAB).perform()
ekostadinov
  • 6,642
  • 3
  • 24
  • 46
  • Okey, it is useful answer man, I will check it out maybe in the future tests;) Thanks! – Sowiarz Sep 19 '14 at 09:45
  • It will be faster to do a .SendKeys() directly rather than scrolling down to the element and the doing a .Click() on it – bit Sep 19 '14 at 10:57
  • Actually this was one of my custom-made solutions - please see my updated answer. – ekostadinov Sep 19 '14 at 11:21
  • Tried everything: scrolling, scroll wheel, etc. The only thing that works is Keyboard.SendKeys("{TAB}"); (as many times as needed to get the control showing on the screen.) Ridiculous! – starmandeluxe Oct 18 '17 at 08:53
  • I know :) did u tried raw JS with `IJavascriptExecutor.ExecuteScript("click-elem-here");` – ekostadinov Oct 18 '17 at 12:50
1

I realize this is a super old question, but it came up while searching a nearly identical problem in the present day. After attempting many of the fixes described here and getting new exceptions for my trouble (mostly stale element and http request timeouts) I stumbled across this issue on Selenium's GitHub.

As described in the post, Chrome had advanced beyond the abilities of my version of chromedriver.exe--my v2.30 driver had known issues with clicking elements due to changes in Chrome v61 scrolling mechanics. Updating to the latest chromedriver.exe solved all my problems.

tl/dr: ensure your version of chromedriver is compatible with the version of Chrome being tested.

jdmac020
  • 527
  • 1
  • 5
  • 17
1

I was getting issue that login button is not clickable in chrome even xpath was correct. after browsing many sites, i came to the solution - use .submit() instead of .click() and it worked perfectly.

driver.findElement(By.xpath("//button[@id='loginBtn']")).click();
driver.findElement(By.xpath("//button[@id='loginBtn']")).submit();
man_luck
  • 1,485
  • 2
  • 16
  • 38
mgupta
  • 11
  • 2
0

If you're doing anything complicated in your CSS, Chrome can get confused (this has happened to me) and think that the element you're trying to click is covered by another element even though this is not the case.

One way to resolve this is to help Chrome understand the situation correctly by adding z-indexes (you'll need to add relative or absolute positioning also) to unambiguously place the correct element on top of the other.

Anonymous
  • 3,136
  • 2
  • 33
  • 47
0

For me, it was creating this command instead.

driver.FindElementByXPath("id('gender1')").SendKeys(Keys.Space);

For my case, I was interacting with radio control.

jbooker
  • 4,227
  • 1
  • 30
  • 43
0

I have had this problem on FF. This issue happens when your field is not in the view area. The slick way to resolve this issue is to zoom out your browser:

TheNotClickableField.SendKeys(Keys.Control + "-" + "-");

you might want to zoom out more or less according to your page size.

Zaher
  • 1
-1

I. If the button is on the bottom of the page, the following code could be used to get you to the bottom via JavaScript from where the click can be executed:

(driver as IJavaScriptExecutor).ExecuteJavaScript("window.scrollTo(0,document.body.scrollHeight - 150)");

The same action could be done via C# with the Actions class provided by Selenium. This will get you to the bottom of the page----->

new Actions(Driver).SendKeys(Keys.End).Perform();

Keys.End could be switched with Keys.PageDown // Keys.Space

II. If you want to get to the exact position of the element you can:

1.Get the element's Y location---> var elementToClick = driver.findElement(By.{Anything}(""));

2.Execute the following JS---> (driver as IJavaScriptExecutor).ExecuteScript(string.Format("window.scrollTo(0,{0})", elementToClickYLocation.Location.Y));

3.Click the element---> elementToClick.click();