SeleniumBasic操作运行中的Chrome浏览器

今天用免费云服务器,三丰云,做操作浏览器自动化的VB程序。

如何自动化已经打开的浏览器?

http://chromedriver.storage.googleapis.com/index.html

首先寻找驱动,最新的驱动只支持到浏览器114,我在网上下载的浏览器是94.0.4606.81(64位版本),selenium驱动下载的是94.0.4606.61/chromedriver_win32.zip,位数不一致竟然也可以。

浏览器和驱动都解压或安装到I:\install\Chrome94\ 文件夹下。

命令行中输入以下命令:

"I:\install\Chrome94\Google94.exe" --remote-debugging-port=9999 --user-data-dir="C:\Windows\Temp"

输入以上命令,打开了浏览器。

bash 复制代码
Private WD As SeleniumBasic.IWebDriver
'"I:\install\Chrome94\Google94.exe" --remote-debugging-port=9999 --user-data-dir="C:\Windows\Temp"
Sub Baidu()
    'On Error GoTo Err1
    Dim Service As SeleniumBasic.ChromeDriverService
    Dim Options As SeleniumBasic.ChromeOptions
    Set WD = New SeleniumBasic.IWebDriver
    Set Service = New SeleniumBasic.ChromeDriverService
    With Service
        .CreateDefaultService driverPath:="I:\install\Chrome94\"
        .HideCommandPromptWindow = True
    End With
    Set Options = New SeleniumBasic.ChromeOptions
    With Options
        .BinaryLocation = "I:\install\Chrome94\Google94.exe"
        .DebuggerAddress = "127.0.0.1:9999"
    End With
    WD.New_ChromeDriver Service:=Service, Options:=Options
    WD.url = "https://www.baidu.com"
End Sub
Private Sub Form_Load()
Baidu
End Sub

运行以上代码,在打开的浏览器,打开了百度。

相关推荐
libolei10 小时前
chrome浏览器安装axure插件
前端·chrome·chrome插件
tecwlcvi32310 小时前
安卓版谷歌地图,Google地图高清版,谷歌地球,谷歌翻译,谷歌(Chrome)浏览器,手机版Edge,浏览器等安卓版浏览器下载
前端·chrome·edge
secondyoung12 小时前
WPS宏使用:一键批量调整图片与表格格式
经验分享·word·lua·markdown·wps·vb
Smile_Gently13 小时前
Ubuntu 20.04 安装 Nginx 详细操作文档
chrome·nginx·ubuntu
感谢地心引力13 小时前
【Chrome-Edge-Firefox】浏览器插件开发
前端·chrome·edge·firefox
qq_2965446513 小时前
安卓版Google(谷歌地球),安卓谷歌(Google)地图,谷歌翻译,谷歌(Chrome)浏览器,手机版Edge,浏览器等安卓版浏览器下载
前端·chrome
liweiweili1261 天前
Linux 中查询指定目录下查找包含特定文本的文件
linux·运维·chrome
碧水澜庭1 天前
Mac升级集成Gemini的Chrome浏览器完整指南
chrome·macos·ai编程
k8s-open2 天前
解决“Argument list too long”错误:curl参数过长的优雅处理方案
linux·前端·chrome·ssh
这样の我2 天前
java 模拟chrome tls指纹
java·开发语言·chrome