Search code examples
pythonselenium-webdriverselenium-chromedriverrobotframework

Open browser profile in robot framework


Can you help me. I want to use the browser profile that I currently have. The folder location is: C:\Users\worm\AppData\Local\Google\Chrome\User Data\Default

I failed to open it using this code.. maybe you can give me the code to open the browser profile that I have using the robot framework.

here is the code that I use :

*** 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}

I hope I can open the chrome profile that I have to do a test


Solution

  • It is not an answer, just continue discussion.

    1. the line ${options.add_argument}= Set Variable -- ... isn't correct

      Use Call Method ${options} add_argument --... instead

    2. option= -> chrome_options for Create Webdriver keyword.

    3. Just in case equal sign could/should be escaped for add_argument. = -> \= So RobotFramework could understand that it is one value that should be passed as is and shoudn`t be split.

    So, could you try in result:

        ${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\=C:/Users/cacing/AppData/Local/Google/Chrome/User Data
        Call Method    ${options}   add_argument  --profile-directory\=Profile 9
        Create WebDriver   Chrome   chrome_options=${options}
        go to  chrome://version
    
    
    1. Precaution, the example is valid for Selenium below 4.10.0, e.g. I checked on Selenium 4.9.1