【问题标题】:ChromeDriver 76.0.3809.68 is throwing exception with SelectByVisibleText method: Script returns unexpected resultChromeDriver 76.0.3809.68 使用 SelectByVisibleText 方法引发异常:脚本返回意外结果
【发布时间】:2019-08-01 18:59:42
【问题描述】:

我已将 selenium chromedriver 更新为 76.0.3809.68,现有测试开始失败,新的 Select(webElement).selectByVisibleText(value) 失败并出现以下异常

org.openqa.selenium.WebDriverException: unknown error: script returns unexpected result
  (Session info: chrome=76.0.3809.87)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'VARGHESEV10', ip: '10.13.36.28', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_144'
Driver info: com.prahs.framework.PRAWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 76.0.3809.87, chrome: {chromedriverVersion: 76.0.3809.68 (420c9498db8ce..., userDataDir: C:\Users\swqatest\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:15612}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webdriver.remote.sessionid: cfd7ddc498272f40f9b62c43f67...}
Session ID: cfd7ddc498272f40f9b62c43f6742060
*** Element info: {Using=xpath, value=.//option[normalize-space(.) = "Test_Auto_Pv_243399_RAJ"]}


protected void selectOption(String field, WebElement selectElement, String value) {
    log.info(ReportUtils.formatAction("Select ", field, value));
    Select select = new Select(selectElement);
    select.selectByVisibleText(value);
}

【问题讨论】:

  • 显示元素的html结构
  • 检查此版本的 chromedriver 是否与您当前的 chrome 版本兼容。如果没有,请将 chrome 升级到兼容版本。
  • 我已将 Chrome 和 Chrome 驱动升级到 76 版本
  • 好消息是 V75 驱动程序似乎可以与 Chrome V76 一起使用。

标签: selenium selenium-chromedriver


【解决方案1】:

我遇到了同样的问题,但在降级驱动程序版本后工作正常:Chrome 为 76 (76.0.3809.100),驱动程序为 75 (75.0.3770.140)

【讨论】:

  • 这对我有用,很高兴知道你仍然可以使用 chromedrive 75
【解决方案2】:

不是真正的修复,但这是由于对问题 3084 所做的修复:在使用prototype.js 1.6.1 时,Find Elements not working in ChromeDriver 76 [Pri-2], select tags are not working. Just the presence ofprototype.js` 就足够了这是失败的。您可以尝试以下方法重新创建

<html>
    <head>
        <title>test</title>
    </head>

    <body>
        <select id="sample">
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
        </select>

        <script src="https://ajax.googleapis.com/ajax/libs/prototype/1.6.1/prototype.js" type="text/javascript"></script>
    </body>
</html>

错误:

org.openqa.selenium.WebDriverException: unknown error: script returns unexpected result
  (Session info: chrome=77.0.3865.75)

如果你有应用程序的控制权,你可以升级prototype.js的版本。

【讨论】:

    【解决方案3】:

    在将 Chrome 更新到版本 76.0.3809.87 并将驱动程序更新到最新版本后,我遇到了同样的问题,但工作正常

    【讨论】:

      【解决方案4】:

      ChromeDriver 76.0.3809.68 和 Chrome 76.0.3809.100 也遇到过这个问题。 它适用于 ChromeDriver 76.0.3809.126 和 Chrome 76.0.3809.100。

      【讨论】:

        【解决方案5】:

        不仅selectByVisibleText 甚至selectByValue 也抛出了同样的异常

        “org.openqa.selenium.WebDriverException:未知错误:脚本返回 意想不到的结果”。

        我在使用 chrome v76 时遇到了这个问题。 我将 chrome 版本升级到 77 并使用 ChromeDriver 76 和 77 进行了测试,现在可以正常工作。

        【讨论】:

          【解决方案6】:

          我认为此问题的修复程序已在 chrome 76.0.3809.126 中发布,请检查。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2019-08-06
            • 2017-07-14
            相关资源
            最近更新 更多