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

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

相关推荐
命运之光19 小时前
【最新】ChromeDriver最新版本下载安装教程,ChromeDriver版本与Chrome不匹配问题
前端·chrome
裤裤兔1 天前
python爬取pdf文件并保存至本地
chrome·爬虫·python·pdf·网络爬虫
bitbrowser1 天前
实操总结:如何高效导入Chrome书签到指纹浏览器?
前端·chrome·python
serve the people2 天前
HTML Document Loaders in LangChain
chrome·langchain·html
凄戚3 天前
bash和命令
开发语言·chrome·bash
Evan芙3 天前
Bash 变量命名规则与类型使用
linux·运维·开发语言·chrome·bash
wyjcxyyy3 天前
polar靶场-MISC,WEB(中等)
前端·chrome
女生寝室0383 天前
《Chrome》 [142.0.7444.60][绿色便携版] 下载
前端·chrome
CS_浮鱼3 天前
【Linux】基础IO
linux·运维·chrome
Keely402854 天前
学习编写chrome插件:Hello World 扩展
前端·chrome