找回密码
 加入
搜索
查看: 205|回复: 2

[网络通信] ChromeDriver自动控制Chrome无法打开网页问题【已解决】

[复制链接]
发表于 2024-8-30 09:34:27 | 显示全部楼层 |阅读模式
本帖最后由 kemyliu 于 2024-8-30 15:35 编辑

各位大佬,我是照猫画虎学习"绿色风"大佬的《AU3自动化操作谷歌Chrome浏览器示例》来完成的代码。
之前都是可以的,现在Win10更新后发现原来的代码不能打开网页了。
@绿色风 大佬帮忙看下!!
Au3 Webdriver下载地址:
Release 1.3.1 · Danp2/au3WebDriver · GitHub

ChromeDriver下载网址:
Chrome for Testing availability (googlechromelabs.github.io)

在英文论坛找到了暂时的解决方法:
解决此问题的方法: 128版本的chromedriver就有这样的问题,换成127版本的就没有问题了。
Chromedriver issues August 2024 - Page 2 - AutoIt General Help and Support - AutoIt Forums (autoitscript.com)
代码示例如下:

Opt("TrayIconHide",1)
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <StaticConstants.au3>
#include <File.au3>
#include <Date.au3>
#include <Excel.au3>
#include <GuiRichEdit.au3>
#include <..\MyInclude\wd_capabilities.au3>
#include <..\MyInclude\wd_helper.au3>
$WebDriver="D:\Program Files\chrome-win64\chromedriver.exe"
WinKill("[title:" &$WebDriver )
_WD_Option('Driver', $WebDriver)
;_WD_Option('DriverParams', '--verbose --log-path="' &@ScriptDir &'\chrome.log"')
_WD_Option('Port',9515) ;端口
Local $sDesiredCapabilities = '{"capabilities": {"alwaysMatch": {"goog:chromeOptions": {"w3c": true,  "excludeSwitches": [ "enable-automation"], "useAutomationExtension": false }}}}'
_WD_Startup()
If @error Then
        MsgBox(0,"Error","启动失败!!")
EndIf
Dim $sSession = _WD_CreateSession($sDesiredCapabilities)
_WD_Window($sSession, "Maximize") ;最大化打开窗口
_WD_Navigate($sSession, "www.baidu.com")
发现更新系统后edge自动后台启动多了一堆msedgewebview2.exe的进程。在之前调试的时候也发现,如果msedgedriver.exe有运行的话chromedriver.exe也会出现打开的port是0的状况。
Starting ChromeDriver 130.0.6681.0 (1d6189109c46cca8f3f2e2074b99f28e2c6b17d8-refs/branch-heads/6681@{#1}) on port 0

以前成功的时候这里port都是9515.











本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?加入

×
发表于 2024-8-30 13:04:18 | 显示全部楼层
不同版本的Chrome浏览器需要下载对应版本的chromedriver.exe
 楼主| 发表于 2024-8-30 13:09:05 | 显示全部楼层
zghwelcome 发表于 2024-8-30 13:04
不同版本的Chrome浏览器需要下载对应版本的chromedriver.exe

用的就是和chrome版本一致的chromeDriver.

再分享一个下载ChromeDriver和浏览器的下载地址:
https://googlechromelabs.github.io/chrome-for-testing/#stable
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 13:46 , Processed in 0.078801 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表