当前位置: 首页 > 知识库问答 >
问题:

硒。JavascriptException:javascript错误:未能对“文档”执行“elementFromPoint”:提供的双精度值是非有限的

饶承宣
2023-03-14

使用Chrome78和chromedriver78当我单击音频文件或尝试使用selenium tests停止音频时,我遇到此错误。

错误:

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

请注意,这种情况只发生在远程webdriver上,并且不一致。

错误堆栈跟踪:

当“item_1”元素的音频播放器在“[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)

共有3个答案

李康安
2023-03-14

我在尝试单击AngularJS网格中的单元格时遇到了同样的问题。我确认XPath查询只产生一个结果,然后研究添加等待条件是否有帮助。正如添加错误一样,允许在此处继续添加,而不允许在此处等待。

下面的代码是我用来单击单元格的方法。我从Click()切换到了Action,因为Click()方法被另一个元素截获。

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

WaitConditions是一个单独的类,用于对不推荐使用的ExpectedConditions包的某些行为进行建模。

下面是上面使用的WaitConditions内部的方法。

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;
        }
    };
}
柯昆
2023-03-14

我也遇到过同样的问题,只需将窗口向下滚动到目标元素,就可以解决这个问题。元素似乎没有显示在视口中,这就是为什么selenium看不到它的原因。

在找到并单击元素之前,尝试添加以下行:

driver.execute_script("window.scrollTo(0, window.scrollY + 100)")
driver.implicitly_wait(3) 
狄兴邦
2023-03-14

我也有同样的问题,观察结果是,同一个xpath有多个元素。找到不同的唯一xpath解决了这个问题

 类似资料:
  • 所以我对selenium在HTML中点击隐藏导航栏有问题。。。我需要单击操作按钮,然后单击导出(Excel)。 目前,我将其设置为aria labeledby=share,这假设我想要单击导出(CSV)并执行任务(当脚本想要工作时……如果没有,则我会得到下面的错误)。当我试图设置或并将其指向Export(Excel)时,它不起作用。所以我现在把它设置为aria labeledby=Share,这可

  • 我最近更新了我的chrome版本,即,并从这里下载了兼容的chromedriver 我已经开始面对这个错误了。在详细调试时,我发现类导致了这个问题。无论我在代码中选择一个下拉菜单,我都会遇到这个问题。 下拉列表的HTML如下代码片段所示: 我使用下面的代码来选择一个值 错误stacktrace Javascript错误:在“Document”上执行“Elements frompoint”失败:提供

  • 问题内容: 我只是在尝试使用硒在Mac上做一些非常基础的事情,甚至无法打开网页。我收到一个错误: 这是我的代码如下: 问题答案: 错误说明了一切: 该错误明确指出正在检测到的 chromedriver 具有错误的权限。 解 从ChromeDriver-WebDriver for Chrome下载最新的 chromedriver 二进制文件并将其保存在系统中。 确保 chromedriver 二进制

  • 问题内容: 如何使用正则表达式从字符串中提取双精度值。 问题答案: 这是简单的方法。请勿将regex用于内置类型。

  • 问题内容: 我正在编写一个简单的Java程序。我需要从输入中获取一个字符串并将其分为两部分:1-double 2-string。然后,我需要对double进行简单的计算,并将结果发送到具有特定精度的输出(4)。它工作正常,但是当输入为0时出现问题,则不能正常工作。 例如,对于这些输入,输出将是: 1公斤 输出:2.2046 3.1公斤 输出:6.8343 但是当输入为0时,输出应为0.0000,但

  • 问题内容: 如何使用正则表达式从字符串中提取双精度值。 问题答案: 是简单的方法。请勿将regex用于内置类型。