报错截图
java.io.IOException: Invalid Status code=403 text=Forbidden
Exception in thread "main" org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:60613/devtools/browser/747cc62c-8bb8-4828-ab4e-afa69400a604
Build info: version: '4.1.2', revision: '9a5a329c5a'
System info: host: 'LAPTOP-T3AB0U7F', ip: '192.168.127.120', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_121'
Driver info: driver.version: ChromeDriver
1.首先排除了浏览器版本和selenium版本不一致的问题
2.WebDriver服务启动后提示 Only local connections are allowed.
这个是因为Chrome默认不允许跨机器调试,只需要给启动命令加上白名单即可。
System.setProperty("webdriver.chrome.whitelistedIps", "");
3.问题还未解决
最后排查是
selenium-java的版本设置太高导致的由<version>4.0.0</version>降到3.141.59
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
问题解决