10

using chrome 78 and chromedriver78 When i click an audio file or try to stop an audio using selenium tests i am getting this error.

Error:

org.openqa.selenium.JavascriptException: javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.

Note it happens only with remote webdriver and its not consistent.

Error stack trace:

When the audio player of the "item_1" element is stopped in "[data-rcfid='checkbox_7']"

org.openqa.selenium.JavascriptException: javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite.
  (Session info: chrome=78.0.3904.70)
Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:26:55.152Z'
System info: host: 'ip-10-0-10-137', ip: '10.0.10.137', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-71-generic', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 78.0.3904.70, chrome: {chromedriverVersion: 78.0.3904.70 (edb9c9f3de024..., userDataDir: C:\Windows\proxy\scoped_dir...}, goog:chromeOptions: {debuggerAddress: localhost:1674}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: accept, webdriver.remote.sessionid: eb7d4195af3426c181317a16028...}
Session ID: eb7d4195af3426c181317a160286b15e0125b619
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:545)
    at org.openqa.selenium.remote.RemoteWebDriver.perform(RemoteWebDriver.java:611)
    at org.openqa.selenium.interactions.Actions$BuiltAction.perform(Actions.java:638)
    at webDriver.Driver.click(Driver.java:147)
    at pageObjects.ActivityPageObject.clickAudioInlineStopIn(ActivityPageObject.java:205)
    at stepDefinition.Activity.theAudioPlayerOfTheElementIsStoppedIn(Activity.java:61)
    at ✽.When the audio player of the "item_1" element is stopped in "[data-rcfid='checkbox_7']"(/opt/atlassian/bamboo-home/xml-data/build-dir/16744451/RCF1-RMIT-BROW3/rcf-automation-tests/src/test/resources/featureFiles/interactions/markedInteractions/CheckBox.feature:433)
DebanjanB
  • 118,661
  • 30
  • 168
  • 217
Tabassum
  • 119
  • 1
  • 1
  • 4

7 Answers7

13

I had same issue and observation was , multiple elements by same xpath. Finding different unique xpath resolved it

Hietsh Kumar
  • 851
  • 6
  • 14
  • I downgraded my chrome version to chrome 75(which should not be the correct way) which is a stable one for a quick fix – Tabassum Jan 17 '20 at 20:34
  • Hi, as per my case , if there are 2 or more elements by same , ID,XPATH,NAME ,or whatever way you are using this error occurrs , so you can find unique xpath , or target the element by other way like class, link text , or text contains....in chrome to check Carl+shift +I then in ctrl + f and search there ,, identity of element should be unique – Hietsh Kumar Jan 19 '20 at 17:50
3

I have faced the same issue and was able to resolve it by simply scrolling the window down to the element I am targeting. Seems like the element wasn't showing in the viewport and that's why it wasn't visible to selenium.

Try to add the following lines before finding and clicking the element:

driver.execute_script("window.scrollTo(0, window.scrollY + 100)")
driver.implicitly_wait(3) 
Rola
  • 649
  • 4
  • 8
0

I experienced this same issue while trying to click a cell in an AngularJS grid. I confirmed that my XPath query resulted in only one result, and then explored if adding in a Wait Condition would help. As it turned out, adding in a Wait here allowed the code to continue without error.

The below code is the method I used to click the cell. I switched from Click() to an Action as the Click() method was being intercepted by a different element.

public void ClickEmploymentChangeLogButton()
{
    Wait.Until(WaitConditions.ElementIsVisibleAndEnabled(EmploymentChangeLogButton));
    Actions actions = new Actions(driver);
    actions.MoveToElement(EmploymentChangeLogButton).Perform();
    actions.MoveToElement(EmploymentChangeLogButton).Click().Perform();
}

WaitConditions is a separate class to model some of the behaviour of the deprecated ExpectedConditions package.

Here's the method inside WaitConditions that is used above.

public static Func<IWebDriver, bool> ElementIsVisibleAndEnabled(IWebElement element)
{
    return (driver) =>
    {
        try
        {
            return element.Displayed && element.Enabled;
        }
        catch (Exception)
        {
            // If element is null, stale or if it cannot be located
            return false;
        }
    };
}
Ryan B
  • 191
  • 2
  • 5
  • 16
0

The problem is, that you've found an element that is not graphically displayed in the web browser - location property has value: X=0 and Y=0; so you've probably located a wrong element.

Piotr M.
  • 196
  • 1
  • 6
0

This error message...

Javascript error: Failed to execute 'elementsFromPoint' on 'Document': The provided double value is non-finite

...implies that the WebDriver instance was unable to find the desired element using the Locator Strategy for one or the other reasons:

  • The locator strategy doesn't identifies the desired element uniquely within the DOM Tree.
  • The element haven't loaded properly when you tried to interact with it.
  • Element is within an <iframe> / <frame>
  • The style attribute of the element contains display: none;
  • Element is within an shadow DOM.

Analysis

The relevant HTML would have been helpful to analyze the issue in a better way. However, you need to take care of a couple of things as follows:

  • Ensure that the locator strategy identifies the desired element uniquely within the HTML DOM.

  • Induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:

    • cssSelector:

      new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("elementCssSelector"))).click();
      
    • xpath:

      new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("elementXpath"))).click();
      
  • If the WebElement is within an <iframe> / <frame> you need to induce WebDriverWait for the desired frameToBeAvailableAndSwitchToIt().

You can find a relevant detailed discussion in Is it possible to switch to an element in a frame without using driver.switchTo().frame(“frameName”) in Selenium Webdriver Java?


References

You can find a couple of relevant detailed discussions in:

DebanjanB
  • 118,661
  • 30
  • 168
  • 217
0

I have also faced the same issue. In my case the problem was that the element I tried to move to wasn't visible yet in the browser.

So I used time.sleep(1)

After that it worked.

Martin Brisiak
  • 2,957
  • 12
  • 32
  • 48
Taka
  • 23
  • 1
  • 8
0

This error appeared when I upgraded to ChromeDriver 88 from a version in the 70s (71?). It was actually caused by a workaround from that earlier version. This was using a dropdown in angular. Instead of clicking on an element I had to move to the element and then click on it in separate steps. When I removed the moveToElement steps the error went away

previous code

        masterPage.MasterDropDown.click();
        Thread.sleep(3000);
        actions.moveToElement(masterPage.MasterDropDown).perform();
        Thread.sleep(1000);
        actions.moveToElement(masterPage.DropdownButton1).perform();
        Thread.sleep(1000);
        masterPage.DropdownButton1.click();

Was changed to

        masterPage.MasterDropDown.click();
        masterPage.DropdownButton1.click();

The error went away and it is cleaner.

dstudeba
  • 8,138
  • 3
  • 28
  • 39