Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/selenium/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
设置配置文件Chrome WebDriver Selenium VBA_Vba_Selenium_Google Chrome_Selenium Webdriver_User Profile - Fatal编程技术网

设置配置文件Chrome WebDriver Selenium VBA

设置配置文件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/

我试图在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/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”)
谢谢。我创建了一个新配置文件,并将所有内容从默认文件夹复制到新配置文件。问题解决了!