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

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

相关推荐
哎哟喂_!17 小时前
Node.js 循环依赖问题详解:原理、案例与解决方案
前端·chrome·node.js
Rhys..18 小时前
如何禁止chrome自动更新
前端·chrome
我爱加班、、2 天前
Chrome安装最新vue-devtool插件
javascript·vue.js·chrome·vue-devtool
T0uken3 天前
【Python】UV:单脚本依赖管理
chrome·python·uv
powerfulzyh5 天前
Docker中运行的Chrome崩溃问题解决
chrome·docker·容器
代码的乐趣5 天前
支持selenium的chrome driver更新到136.0.7103.92
chrome·python·selenium
努力学习的小廉5 天前
深入了解linux系统—— 自定义shell
linux·运维·chrome
fenglllle6 天前
macOS 15.4.1 Chrome不能访问本地网络
chrome·macos
yousuotu6 天前
python如何提取Chrome中的保存的网站登录用户名密码?
java·chrome·python
颜淡慕潇7 天前
【Python】超全常用 conda 命令整理
chrome·python·conda