Recently, I updated Google Chrome to the latest version [113.0.5672.127]. Then our friends who usually type codes or do tests know that our selenium operation driver version must also be upgraded to the corresponding version, otherwise it will not work, but I will update the two versions today. After upgrading to the latest version, the startup program still cannot be started. In order to solve this problem, this blog output is unique. Here is the java solution. Just put the corresponding content in python;
1. Google version:
2. Error content;
Starting ChromeDriver 113.0.5672.63 (0e1a4471d5ae5bf128b1bd8f4d627c8cbd55f70c-refs/branch-heads/5672@{#912}) on port 58348 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. [1684831558.261][WARNING]: Deprecated chrome option is ignored: useAutomationExtension [1684831558.261][WARNING]: Deprecated chrome option is ignored: useAutomationExtension May 23, 2023 4:45:58 pm org.openqa.selenium.remote.ProtocolHandshake createSession Information: Detected upstream dialect: W3C May 23, 2023 4:45:59 pm org.openqa.selenium.remote.http.WebSocket$Listener onError Warning: Invalid Status code=403 text=Forbidden java.io.IOException: Invalid Status code=403 text=Forbidden at org.asynchttpclient.netty.handler.WebSocketHandler.abort(WebSocketHandler.java:92) at org.asynchttpclient.netty.handler.WebSocketHandler.handleRead(WebSocketHandler.java:118) at org.asynchttpclient.netty.handler.AsyncHttpClientHandler.channelRead(AsyncHttpClientHandler.java:78) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:327) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:314) at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:435) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:279) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:722) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:658) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:584) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:496) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.base/java.lang.Thread.run(Thread.java:834) Exception in thread "main" org.openqa.selenium.remote.http.ConnectionFailedException: Unable to establish websocket connection to http://localhost:51445/devtools/browser/3d768ac7-b01d-45e8-8f93-9398fb81522b Build info: version: '4.4.0', revision: 'e5c75ed026a' System info: host: 'XIAOXIAO', ip: '192.168.137.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0\ ', java.version: '11.0.2' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.http.netty.NettyWebSocket.<init>(NettyWebSocket.java:102) at org.openqa.selenium.remote.http.netty.NettyWebSocket.lambda$create$3(NettyWebSocket.java:128) at org.openqa.selenium.remote.http.netty.NettyClient.openSocket(NettyClient.java:106) at org.openqa.selenium.devtools.Connection.<init>(Connection.java:77) at org.openqa.selenium.chromium.ChromiumDriver.lambda$new$2(ChromiumDriver.java:116) at java.base/java.util.Optional.map(Optional.java:265) at org.openqa.selenium.chromium.ChromiumDriver.<init>(ChromiumDriver.java:114) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:81) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:70) at util.WebDriverUtils.getNormalWebDriver(WebDriverUtils.java:61) at gongjiYouzi.GongJi.main(GongJi.java:22) Process finished with exit code 1
3. Solution:
Before we operate, we need to get the WebDriver object first, so we need to add the following code when creating ChromeOptions to set parameters:
options.addArguments("--remote-allow-origins=*");
4. The integrated code:
//1. Parameter setting, headless mode ChromeOptions options = new ChromeOptions(); //2. Hide navigator.webdriver options.addArguments("--disable-blink-features=AutomationControlled"); //1, 1 to solve 403 errors options.addArguments("--remote-allow-origins=*"); //3. Close the prompt on the upper left that Chrome is being controlled by the automatic testing software options.setExperimentalOption("useAutomationExtension", false); WebDriver driver = new ChromeDriver(options);