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

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

相关推荐
DiXinWang4 小时前
关闭谷歌浏览器提示“若要接收后续 Google Chrome 更新,您需使用 Windows 10 或更高版本”的方法
前端·chrome
lightgis1 天前
chrome中的axure插件提示无法不受支持
前端·chrome
.小墨迹1 天前
linux删除通过源码安装的库
linux·运维·chrome
馨谙1 天前
Linux中的管道与重定向:深入理解两者的本质区别
前端·chrome
dyxal1 天前
VS Code 1.52.1 对应一些插件版本
前端·chrome
乌萨奇也要立志学C++1 天前
【Linux】基础IO(一)Linux 文件操作从入门到实践:系统调用、文件描述符、重定向,为自定义Shell添加重定向
linux·运维·chrome
技术钱2 天前
uniapp使用音频录音功能
chrome·uni-app·音视频
oh,huoyuyan2 天前
如何在火语言中指定启动 Chrome 特定用户配置文件
前端·javascript·chrome
爱隐身的官人3 天前
谷歌 chrome 浏览器安装crx插件(hackbar为例)
chrome·渗透测试·hackbar
谷歌开发者3 天前
Web 开发指向标 | Chrome 开发者工具学习资源 (一)
前端·chrome·学习