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

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

相关推荐
老兵发新帖4 小时前
Ubuntu版本nvidia-smi提示版本不匹配问题,解决办法
linux·chrome·ubuntu
Fᴏʀ ʏ꯭ᴏ꯭ᴜ꯭.1 天前
Nginx构建PC站点:root与alias详解
运维·chrome·nginx
goxingman2 天前
在 Linux 中查看磁盘运行占用(I/O 使用率)
linux·运维·chrome
铁蛋AI编程实战2 天前
Gemini in Chrome 全实战:解锁+API调用+自定义扩展+本地推理
前端·人工智能·chrome
hbstream海之滨视频网络技术2 天前
Google正式上线Gemini In Chrome,国内环境怎样开启。
前端·chrome
铁蛋AI编程实战2 天前
谷歌MedGemma 1.5医疗大模型开源部署教程:普通显卡可运行,医学影像分析零代码实现
人工智能·chrome·开源
vortex53 天前
深度字典攻击(实操笔记·红笔思考)
前端·chrome·笔记
life码农3 天前
Linux系统清空文件内容的几种方法
linux·运维·chrome
陈希瑞3 天前
OpenClaw Chrome扩展使用教程 - 浏览器中继控制
前端·chrome
2401_859049084 天前
git submodule update --init --recursive无法拉取解决
前端·chrome·git