【问题标题】:Java - Selenium 2 : Chromedriver - Exception calling driver.manage().window().setPosition()Java - Selenium 2:Chromedriver - 异常调用 driver.manage().window().setPosition()
【发布时间】:2017-10-16 09:24:51
【问题描述】:

我正在尝试使用 chromedriver 运行 selenium 测试。要在启动时隐藏 chrome 窗口,我使用以下代码。参考https://sqa.stackexchange.com/a/15489

driver.manage().window().setPosition(new Point(-2000, 0)); 

上面的代码在我的本地 windows 7 操作系统和另一台运行 windows 8 的远程机器上运行良好,但在一台运行 windows 10 的远程机器上失败并出现以下异常。

[66.916][SEVERE]: Timed out receiving message from renderer: -11.117
    Exception in Main org.openqa.selenium.WebDriverException: unknown error: cannot get automation extension 
     from timeout

对于这个例外,我在网上找到的每个答案都只涉及将 chromedriver 和 chrome 更新到最新版本,我已经完成了。

我在所有操作系统中使用相同的版本: 铬驱动程序:2.29.461591 铬版本:58.0.3029.110 硒版本:2.33.0

失败的操作系统信息: Windows 10 家庭版 64 位

任何帮助将不胜感激,谢谢。

【问题讨论】:

    标签: java windows selenium selenium-webdriver selenium-chromedriver


    【解决方案1】:

    只是预感 - 由于您的操作系统是 64 位的,因此您的 Chrome 浏览器很可能也是 64 位的。您可能还安装了 32 位 chrome 并且 webdriver 正在启动可能未更新的 32 位? (再次只是一种预感)。

    首先检查您是 32 位还是 64 位。您应该能够通过单击 Chrome 帮助 > 关于 Google Chrome 来区分它们。

    与下面显示的不同,32 位版本号旁边没有“(64 位)”文本。

    来源:howtogeek.com

    现在在出现错误之前将版本与 webdriver 启动的版本进行比较。

    如果不同,请尝试通过以下方式设置二进制文件:

    ChromeOptions options = new ChromeOptions();
    options.setBinary("path/to/latest/64-bit/chrome/Chrome.exe");
    
    System.setProperty(ChromeDriverService.CHROME_DRIVER_EXE_PROPERTY, "path/to/chrome/driver/chromedriver");
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);
    
    WebDriver driver = new ChromeDriver(capabilities);
    

    只是一种预感,但我希望它有所帮助。

    PS。我在我的机器上尝试了同样的事情,Win7 64 位并且它正在工作。

    【讨论】:

      【解决方案2】:

      尝试更改您的机器分辨率,以便移动的 chrome 窗口不会在远程机器中完全消失。

      【讨论】:

        猜你喜欢
        • 2018-03-29
        • 2020-06-22
        • 1970-01-01
        • 1970-01-01
        • 2021-09-14
        • 2018-04-18
        • 1970-01-01
        • 1970-01-01
        • 2016-04-25
        相关资源
        最近更新 更多