【问题标题】:System.InvalidOperationException : unknown error: Runtime.evaluate threw exception: DOMException error using Azure and Selenium through C#System.InvalidOperationException:未知错误:Runtime.evaluate 抛出异常:DOMException error using Azure and Selenium through C#
【发布时间】:2020-02-21 16:44:05
【问题描述】:

我正在通过 Azure 每日计划运行在远程计算机上运行测试。一些测试失败,错误日志如下。我该如何解决这个问题?

注意:我没有启动 chrome 驱动程序的方法实现,因为我正在引用具有抽象方法的其他解决方案的 dll。

堆栈:NUnit、C#、Selenium、Visual Studio、Azure、log4Net

一次性设置: Automation.Test.Framework.Models.Exceptions.AtGenericException:错误 初始化 WebDriver Chrome ----> System.InvalidOperationException : 未知错误: Runtime.evaluate throw exception: DOMException: Failed to read “Window”中的“localStorage”属性:拒绝访问 文档。在:1:1(会话信息:chrome=77.0.3865.90) (驱动信息:chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),平台=Windows NT 6.3.9600 x86_64)

【问题讨论】:

标签: c# selenium google-chrome selenium-chromedriver azure-automation


【解决方案1】:

此错误消息...

OneTimeSetUp: Automation.Test.Framework.Models.Exceptions.AtGenericException : Error initializing WebDriver Chrome 
System.InvalidOperationException : unknown error: Runtime.evaluate threw exception: DOMException: Failed to read the 'localStorage' property from 'Window': Access is denied for this document. at :1:1 (Session info: chrome=77.0.3865.90) 
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 6.3.9600 x86_64)

...暗示 ChromeDriver 无法启动/生成新的 WebBrowserChrome 浏览器 会话。

您的主要问题是您使用的二进制文件版本之间的不兼容性,如下所示:

  • 您正在使用 chromedriver=2.36
  • chromedriver=2.36 的发行说明明确提及以下内容:

支持 Chrome v63-65

支持Chrome 77版

所以 ChromeDriver v2.36Chrome 浏览器 v77.0

之间存在明显的不匹配

解决方案

确保:

  • ChromeDriver 已更新到当前的ChromeDriver v78.0 级别。
  • Chrome 已更新至当前 Chrome 版本 78.0 级别。 (根据ChromeDriver v78.0 release notes
  • 清理你的项目工作区通过你的IDE重建你的项目只需要依赖。
  • 如果您的基本 Web 客户端 版本太旧,请卸载它并安装最新的 GA 和发布版本的 Web 客户端
  • 进行系统重启
  • 非root用户身份执行@Test
  • 始终在 tearDown(){} 方法中调用 driver.quit() 以优雅地关闭和销毁 WebDriverWeb Client 实例。

【讨论】:

  • 如果这个/任何答案对您有帮助/对您未来的读者有帮助,请投票赞成。
【解决方案2】:

您应该更改默认的 Chrome 功能以允许第三方 cookie:

Disabling Cookies in Webdriver for Chrome/Firefox

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-19
    • 1970-01-01
    • 1970-01-01
    • 2016-05-18
    • 2021-01-12
    • 2019-03-25
    • 1970-01-01
    • 2019-10-17
    相关资源
    最近更新 更多