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

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

相关推荐
前端掘金者H1 小时前
Chrome插件实现WebPush推送通知的功能
前端·chrome
HEX9CF1 小时前
【Linux】awk 命令详解及使用示例:结构化文本数据处理工具
linux·chrome·算法
会飞的鱼先生3 小时前
javascript中Cookie、BOM、DOM的使用
前端·javascript·chrome
全栈陈序员7 小时前
前端文件下载常用方式详解
前端·javascript·chrome·ajax·css3·html5·safari
qq_336411759 小时前
【笔记】Chrome浏览器的性能调试(performance)工具使用和代码优化
前端·chrome·笔记
Sapphire~19 小时前
Linux-07 ubuntu 的 chrome 启动不了
linux·chrome·ubuntu
去旅行、在路上19 小时前
chrome使用手机调试触屏web
前端·chrome
waterHBO2 天前
修改 vscode 左侧导航栏的文字大小 (更新版)
ide·chrome·vscode·编辑器
鱼与宇2 天前
WebSphere(WAS)
前端·chrome
梓䈑2 天前
【Linux系统】命令行参数 和 环境变量(含内建命令介绍)
linux·运维·chrome