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

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

相关推荐
herogus丶41 分钟前
【Chrome】‘Good助手‘ 扩展程序使用介绍
前端·chrome
旷世奇才李先生4 小时前
XML DOM 安装使用教程
xml·前端·chrome
GuokLiu7 小时前
250708-通过两块硬盘拷贝DeepSeek两个满血版模型的bash脚本
开发语言·chrome·bash
典学长编程2 天前
Linux操作系统从入门到精通!第二天(命令行)
linux·运维·chrome
百锦再2 天前
.Net配置文件appsetting.json的几种读取方法
chrome·json·.net·依赖注入·appsetting·web.config
大猫会长2 天前
mac中创建 .command 文件,执行node服务
前端·chrome
未来之窗软件服务2 天前
chrome webdrive异常处理-session not created falled opening key——仙盟创梦IDE
前端·人工智能·chrome·仙盟创梦ide·东方仙盟·数据调式
涛哥码咖3 天前
chrome安装AXURE插件后无效
前端·chrome·axure
Joker`s smile3 天前
Chrome安装老版本、不同版本,自制便携版本用于前端调试
前端·chrome
weixin_416639973 天前
爬虫工程师Chrome开发者工具简单介绍
前端·chrome·爬虫