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

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

相关推荐
林克爱塞尔达20 小时前
Linux入门(二)
linux·运维·chrome
Larry_zhang双栖1 天前
低版本Chrome 内核兼容性问题的优美解决
前端·chrome
allanGold2 天前
【Chrome】chrome 调试工具的network选项卡,如何同时过滤出doc js css
chrome·调试·devtools·技巧·network选项卡
itxh6662 天前
Chrome浏览器 “此扩展程序不再受支持,因此已停用” 解决方案
chrome·插件·chrome浏览器
恣艺2 天前
Redis有序集合(ZSet):排行榜功能的最优解,原理与实战
数据库·chrome·redis
伐尘3 天前
【CE】图形化CE游戏教程通关手册
前端·chrome·游戏·逆向
John_ToDebug3 天前
浏览器稳定性提升之路:线上崩溃率优化中的 Return 与 CHECK 之争
c++·chrome
zhangfeng11333 天前
R geo 然后读取数据的时候 make.names(vnames, unique = TRUE): invalid multibyte string 9
开发语言·chrome·r语言·生物信息
未来之窗软件服务3 天前
浏览器开发CEFSharp (十七)网页自定义下载—仙盟创梦IDE
chrome·浏览器开发·cefsharp·仙盟创梦ide·东方仙盟
John_ToDebug4 天前
Chrome性能黑魔法:深入浅出PGO优化与实战指南
c++·chrome