设置配置文件Chrome WebDriver Selenium VBA
我试图在chrome中设置一个配置文件,但它不起作用 Chrome版本:版本80.0.3987.106 网络驱动程序:ChromeDriver 80.0.3987.106 硒碱性:SeleniumBasic-2.0.9.0.exe设置配置文件Chrome WebDriver Selenium VBA,vba,selenium,google-chrome,selenium-webdriver,user-profile,Vba,Selenium,Google Chrome,Selenium Webdriver,User Profile,我试图在chrome中设置一个配置文件,但它不起作用 Chrome版本:版本80.0.3987.106 网络驱动程序:ChromeDriver 80.0.3987.106 硒碱性:SeleniumBasic-2.0.9.0.exe Option Explicit Public Sub openGChrome() Dim obj As New WebDriver Dim i As Integer Const URL = "https://www.linkedin.com/
Option Explicit
Public Sub openGChrome()
Dim obj As New WebDriver
Dim i As Integer
Const URL = "https://www.linkedin.com/feed/"
Const JS_PROFILE As String = "C:\Users\ChuckNorris\AppData\Local\Google\Chrome\User Data\Default"
Set obj = New ChromeDriver
With obj
.SetProfile JS_PROFILE, True
.Get URL
Stop
.Quit
End With
End Sub
我做错了什么?有什么帮助吗
编辑:
浏览器已打开,但我没有选择任何配置文件,我无法在未登录的情况下登录网站您没有指定“不工作”的内容,但我认为您应该从配置文件路径中删除\Default,因为当您没有指定配置文件的名称时,意味着您要使用默认名称,然后隐式添加\默认值
要指定默认配置文件以外的特定配置文件,您需要使用:
.AddArgument ("profile-directory=foldername") 'foldername is the name of the folder with the profile you want to use
检查此项大约32/64位如此接近,浏览器以正确的配置文件打开,但我得到错误:无效参数用户数据目录已在使用请为--user data dir参数指定唯一值,或者不要使用--user data dir,这是因为通过selenium打开另一个具有相同配置文件的会话时,浏览器处于打开状态,您已经在使用user data文件夹了。因此,解决方案是在启动脚本之前关闭Chrome,或者创建另一个配置文件并将用户数据文件夹复制到另一个位置。然后使用
AddArgument(“--user data dir=C:\location\u of_the_user\u data\u folder”)
和AddArgument(“profile directory=Name\u of_the_profile\u folder”)
谢谢。我创建了一个新配置文件,并将所有内容从默认文件夹复制到新配置文件。问题解决了!