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

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

相关推荐
kyriewen119 小时前
我开发的 Chrome 扒图浏览器插件又更新了❗
前端·javascript·chrome·科技·ai
2601_9552564710 小时前
服务器入侵应急响应SOP:从发现挖矿病毒到安全加固的完整操作流程
服务器·chrome·安全
YJlio19 小时前
7.4.5 Windows 11 企业网络连接与网络重置实战:远程访问、本地策略与故障恢复
前端·chrome·windows·python·edge·机器人·django
剑神一笑1 天前
Linux awk 命令:文本处理的瑞士军刀
linux·运维·chrome
kyriewen1 天前
我开发的 Chrome 扒图浏览器插件又更新了❗
前端·chrome·浏览器
兄弟加油,别颓废了。1 天前
系统全功能详细操作手册,从启动到测试
前端·chrome
剑神一笑1 天前
Linux xargs 命令深度解析:从管道到命令构建的桥梁
linux·运维·chrome
yuyu_03041 天前
SOHE-晨检仪-手部异常识别算法
前端·chrome
qq_254674412 天前
Ubuntu 20.04取消自动休眠的三种实现方案
linux·chrome·ubuntu