selenium操作谷歌浏览器,驱动使用最新版113版本,启动程序报403解决方式

这篇具有很好参考价值的文章主要介绍了selenium操作谷歌浏览器,驱动使用最新版113版本,启动程序报403解决方式。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

最近我将谷歌浏览器更新到最新版本【113.0.5672.127】,那么我们平时敲代码或者干测试的朋友知道,我们selenium的操作驱动版本也得提升到对应的,不然操作不了,但是我今天将两者都升级到最新版本后,启动程序依旧启动不了,为了解决该问题特有此博客产出,这里是java的解决办法,python的将对应内容放进去就行;

1、谷歌版本:

selenium操作谷歌浏览器,驱动使用最新版113版本,启动程序报403解决方式,selenium,selenium,测试工具,java

2、报错内容; 

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
5月 23, 2023 4:45:58 下午 org.openqa.selenium.remote.ProtocolHandshake createSession
信息: Detected upstream dialect: W3C
5月 23, 2023 4:45:59 下午 org.openqa.selenium.remote.http.WebSocket$Listener onError
警告: 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、解决办法:

我们操作之前,都需要先获取到WebDriver对象,所以我们需要在创建 ChromeOptions 设置参数的时候加上下面的代码即可:    文章来源地址https://www.toymoban.com/news/detail-628850.html

options.addArguments("--remote-allow-origins=*");

4、整合后的代码:

         //1、参数设置,无头模式
        ChromeOptions options = new ChromeOptions();
        //2、隐藏 navigator.webdriver
        options.addArguments("--disable-blink-features=AutomationControlled");

        //1、1解决403错误
        options.addArguments("--remote-allow-origins=*");

        //3、关闭左上方Chrome 正受到自动测试软件的控制的提示
        options.setExperimentalOption("useAutomationExtension", false);
        WebDriver driver = new ChromeDriver(options);

到了这里,关于selenium操作谷歌浏览器,驱动使用最新版113版本,启动程序报403解决方式的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • Selenium安装WebDriver:ChromeDriver谷歌浏览器驱动下载安装与使用最新版118/119/120

    在使用之前的代码通过selenium操作Chrome浏览器时,安装中遇到了Chrome版本与浏览器驱动不匹配的的问题,在此记录安装下过程 我们首先确定自己的Chrome版本 Chrome设置-关于Chrome 可以看到,当前chrome是最新版本:119.0.6045.124(正式版本) (64 位)。 或者在浏览器的地址栏,输入

    2024年02月05日
    浏览(39)
  • 免费 Selenium各大浏览器驱动【谷歌chrme、火狐Firefox、IE浏览器】

    aardio群 625494397 废话不多说 直接开整! 竟然还有脸收费 服了 下载对应版本的浏览器驱动 目标网址 应用场景 Selenium库涉及到 安装selenium库 下载对应浏览器驱动 找到浏览器对应版本 最后直接上代码

    2024年02月16日
    浏览(41)
  • Python--使用selenium通过chromedriver调用谷歌浏览器

    原文网址:Python--使用selenium通过chromedriver调用谷歌浏览器_IT利刃出鞘的博客-CSDN博客         本文用实例介绍Python如何使用selenium通过chromedriver调用谷歌浏览器。 谷歌浏览器访问:chrome://version/ 注意:通过【帮助= 关于Google Chrome 】这种方式来查看会导致谷歌浏览器自动更新

    2023年04月21日
    浏览(82)
  • 使用selenium启动谷歌Chrome浏览器打开指定网站,页面空白,而使用其它浏览器手动打开该网站则正常

    在使用python实现自动化网络爬虫时,我使用到selenium来驱动谷歌Chrome浏览器来打开某一个网页,然后爬取数据,当使用Python中的selenium库驱动Chrome浏览器打开特定网站时,页面内容为空白,但在其他浏览器中手动访问该网站则显示正常。

    2024年02月07日
    浏览(41)
  • python使用selenium 打开谷歌浏览器闪退, 怎么解决

    在使用 Selenium 操作 Chrome 浏览器时,如果 Chrome 浏览器闪退,则可能是以下几个方面出现了问题: 1. Chromedriver 版本与 Chrome 浏览器版本不匹配 你需要确保你正在使用的 Chromedriver 版本与你的 Chrome 浏览器版本匹配。你可以在 Chromedriver 官网上找到最新版本的 Chromedriver,并下载

    2024年02月11日
    浏览(33)
  • 使用Selenium需要浏览器驱动与浏览器版本统一

    安装浏览器驱动 针对不同的浏览器,需要安装不同的驱动。 这里以安装 Chrome 驱动作为演示。 确定浏览器版本 进入设置界面,然后选择 【关于 Chrome】 查看自己的版本信息。这里我的版本是114,下载对应版本的 Chrome 驱动即可。 下载驱动 打开Chrome驱动。单击对应的版本。(

    2024年02月08日
    浏览(38)
  • python使用selenium 打开谷歌浏览器闪退解决办法

    在使用 Selenium 操作 Chrome 浏览器时,如果 Chrome 浏览器闪退,则可能是以下几个方面出现了问题: 1. Chromedriver 版本与 Chrome 浏览器版本不匹配 你需要确保你正在使用的 Chromedriver 版本与你的 Chrome 浏览器版本匹配。你可以在 Chromedriver 官网上找到最新版本的 Chromedriver,并下载

    2024年02月08日
    浏览(38)
  • 【已解决】使用selenium启动谷歌Chrome浏览器打开指定网站,页面空白,而使用其它浏览器手动打开该网站则正常

    1、在使用python实现自动化网络爬虫时,我使用到selenium来驱动谷歌Chrome浏览器来打开某一个网页,然后爬取数据,代码如下:    2、但是当执行到driver.get(url)访问网站时,页面是空白的,如下所示,没有正常显示该网站的数据    print输出的网页html也只有如下数据: htmlhea

    2024年02月12日
    浏览(43)
  • Selenium元素定位神器工具谷歌浏览器插件-SelectorsHub介绍、安装和使用

    Selenium元素定位神器工具谷歌浏览器插件-SelectorsHub介绍,安装与使用 觉得有帮助的同学可以点个赞!传递给更多人! 目前已经得知chropath不在更新,作者的将转焦点于SelectorsHub。 那么SelectorsHub对比chropath的亮点在哪? 使用自定义属性 而chropath并没有此功能 ,如下图所示 这里主要

    2024年02月02日
    浏览(39)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包