Selenium: element not interactable exception while clicking in C#

Created on 22 Oct 2018  路  4Comments  路  Source: SeleniumHQ/selenium

Meta -
OS: Windows 10
Selenium Version: 3.14.0
Browser: Chrome
Language: C#

There is very strange behavior while clicking a simple element in C# bindings. Every time I am trying to click the element I am seeing the OpenQA.Selenium.ElementNotVisibleException : element not interactable exception. I am sure the element is present as I tried with waiting before the interaction also.

I tried the same setup and element using the Java binding and everything looks fine and I am able to click without any issue.

Following is the exception :
Message: OpenQA.Selenium.ElementNotVisibleException : element not interactable (Session info: chrome=69.0.3497.100) (Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.14393 x86_64)

I tried with tha java Script (IJavaScriptExecutor) also and I am able to click with out an issue and Only issue is with Click() method.

Using this xpath:
//div[@data-offset='0']//span[@title='Click to add to basket']

Expected Behavior -
The element should be clickable.

Actual Behavior -
Throws exception while clicking.

Steps to reproduce -
I can not provide the URL to reproduce the issue as the URL is internal but following is the screenshot with the HTML showing the element for the reference.
click-issue-with-webdriver

R-awaiting answer

All 4 comments

@pgaria Please provide the Selenium code in both Java and C# that shows the discrepancy in behavior. You鈥檒l need to forgive my skepticism, but the two language bindings are (or should be) doing the exact same thing (making an HTTP request to the same URL served by chromedriver.exe) when you call the click method (click() for Java and Click() for .NET). There must be some difference in the code.

Hi @jimevans
Yes, I am also confused with the behavior as the code looks fine to me and the ChromeDriver.exe and Browser is also some for both bindings but still it's not able to click the element. Below is the Code you requested

Java:

driver.findElement((By.xpath("//div[@data-offset='0']//span[@title='Click to add to basket']"))).click();

C#:
Driver.FindElement(By.XPath("//div[@data-offset='0']//span[@title='Click to add to basket']")).Click();

What more I can do for the debugging here if you can suggest ??

For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.

See CONTRIBUTING.md

Closing the issue as there is no reproduction scenario provided.

Was this page helpful?
0 / 5 - 0 ratings