java - Window.Chrome.runtime不适合Selenium Webdriver

标签 java selenium selenium-webdriver selenium-chromedriver

我正在使用 Selenium 进行测试。我注意到手动启动 Chrome 和使用 selenium 启动有不同的行为。经过大量调查后,我将问题分解为 JavaScript 的 window.chrome.runtime ,如果从 selenium 启动,它是 undefined

经过对 Google 的一些研究,我发现人们面临着类似的问题,但他们的解决方案都不适合我。

到目前为止,我已尝试删除 test-type 开关:

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", Arrays.asList("test-type"));

还有其他方法可以让它发挥作用吗?

最佳答案

为我完成这项工作的答案是 https://groups.google.com/forum/#!topic/chromedriver-users/7wF9EHF2jxQ

代码片段:

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", Arrays.asList("test-type"));

关于java - Window.Chrome.runtime不适合Selenium Webdriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52224678/

相关文章:

java - 如何在java中的for-each循环中删除和重置集合?

java - 强制更新 JTable 不起作用

java - 从文件到文件程序的写入

java - 无法应用插件 'com.google.protobuf'

c# - 检查元素是否存在于 Selenium 中

selenium-webdriver - 以编程方式获取 Web 请求发起者

Java 7 字符串 - 子字符串复杂度

java - 如何通过 Java 使用 Selenium 调整元素大小?

selenium - Chrome : fake microphone input for test purpose

javascript - Selenium 3 : JavascriptExecutor returns ReferenceError