使用 Chrome 75 版本时,我用得很好,没有任何错误,但在自动更新到版本 76 后,出现以下错误
[2019-08-10 16:11:52] local.ERROR: sendKeysToActiveElement
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-
14T08:25:53'
System info: host: 'DESKTOP-GLEJ40B', ip: '192.168.0.4', os.name: 'Windows 1
0', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'
Driver info: driver.version: unknown {"exception":"[object]
(App\WebDriver\Exception\UnknownCommandException(code: 0):
sendKeysToActiveElement
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-
14T08:25:53'
System info: host: 'DESKTOP-GLEJ40B', ip: '192.168.0.4', os.name: 'Windows
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'
Driver info: driver.version: unknown at
Driver info: driver.version: unknown at C:\Bitnami\wampstack-7.1.30-
我从Selenium下载并替换了76版的驱动程序,但它不起作用 我应该怎么做才能让它以同样的方式工作?
您可以使用以下代码代替System.setProperty
代码,并在构建路径中添加WebDriverManager 3版本jar文件,无论浏览器版本如何,它都可以正常工作。
WebDriverManager.chromedriver().setup();
DesiredCapabilities dcap = new DesiredCapabilities();
dcap.setCapability("pageLoadStrategy", "none");
ChromeOptions options = new ChromeOptions();
options.merge(dcap);
driver = new ChromeDriver(options);
driver.manage().deleteAllCookies();