我正在使用 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/