你能帮我吗?我想使用我当前拥有的浏览器配置文件。文件夹位置为:C:\Users\worm\AppData\Local\Google\Chrome\User Data\Default
我无法使用此代码打开它。也许您可以给我代码来打开我使用机器人框架的浏览器配置文件。
这是我使用的代码:
*** Settings ***
Library SeleniumLibrary
Library String
*** Variables ***
${BROWSER} Chrome
${ENVIRONMENT} staging
${PROFILE_PATH} C:\Users\cacing\AppData\Local\Google\Chrome\User Data\Default
${CHROME_OPT} add_argument("--user-data-dir=${PROFILE_PATH}")
*** Test Cases ***
Open Existing Chrome Profile
Open Browser url=https://google.com browser=${BROWSER} options=${CHROME_OPT}
我希望我可以打开chrome配置文件来进行测试
\
。 逃跑而不是使用
C:\Users\cacing\AppData\Local\Google\Chrome\User Data
应该是
C:\\Users\\cacing\\AppData\\Local\\Google\\Chrome\\User Data
甚至使用斜杠
C:/Users/cacing/AppData/Local/Google/Chrome/User Data
。
否则你将拥有像
C:UserscacingAppDataLocal ...
这样的价值
--user-data-dir
- 指定用户配置文件的位置
--profile-directory
- 指定现有配置文件名称。
例如
--user-data-dir=C:/Users/cacing/AppData/Local/Google/Chrome/User Data
--profile-directory=My_Profile
你说的我都试过了。但我还是失败了
这是我使用的代码:
${options}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
${options.add_argument}= Set Variable --allow-running-insecure-content
${options.add_argument}= Set Variable --disable-web-security
${options.add_argument}= Set Variable --user-data-dir=C:/Users/cacing/AppData/Local/Google/Chrome/User Data
${options.add_argument}= Set Variable --profile-directory=Profile 9
Create WebDriver Chrome options=${options}
go to chrome://version
Sleep 9s