Robot Framework :- Cannot Open Chrome from Existing Chrome Profile

邮差的信 提交于 2019-11-30 20:33:40

问题


I am trying to Learn Robot Framework. I have already worked on Selenium Webdriver. I was trying to open the Chrome Browser from an Exiting Profile using Create Webdriver Keyword. However i am not able to do . It Seems that Robot Framework Opens a new Chrome Profile Everytime. Here is the Code that i got after goggling, but this is not opening Chrome from the User data folder that i prefer. Any Suggestions or Ideas this can be achieved.

    Open Chrome Using Create WebDriver Keyword
[Tags]  chrome
${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 = /Users/myName/AppData/Local/Google/Chrome/User Data
Create WebDriver  Chrome  chrome_options=${options}
go to  {URL}

# Close Browser


回答1:


To add arguments, call the add_argument method of the ChromeOptions object. Note that you need to escape the '=' in the --user-data-dir argument or Robot Framework will look for an argument called '--user-data-dir' and fail. When testing this I noticed that a profile will be created in the location specified if it does not exist.

Open Chrome Using Create WebDriver Keyword
    ${options}=    Evaluate    sys.modules['selenium.webdriver'].ChromeOptions()    sys, selenium.webdriver
    Call Method    ${options}    add_argument    --allow-running-insecure-content
    Call Method    ${options}    add_argument    --disable-web-security
    Call Method    ${options}    add_argument    --user-data-dir\=/Users/myName/AppData/Local/Google/Chrome/User Data
    Create WebDriver    Chrome    chrome_options=${options}
    Go To    https://stackoverflow.com


来源:https://stackoverflow.com/questions/38226102/robot-framework-cannot-open-chrome-from-existing-chrome-profile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!