Robot Framework - Run Firefox with system proxy

14,458

Assuming you are using Selenium2Library (rather than SeleniumLibrary) the easiest way of achieving this is by creating a firefox profile and passing this in as an argument to the open browser keyword.

1-Create Firefox Profile

Launch profile manager

  • firefox.exe -P (Windows)

  • /Applications/Firefox.app/Contents/MacOS/firefox-bin -profilemanager (OSX)

  • ./firefox -profilemanager (Linux)

Create a new profile (save it to a known location). Open the profile and open the Options dialog, advanced tab. Select "Network" and set the proxy settings as required. Close Options and Firefox.

2-Specify Firefox Profile in Test

${SERVER}                   http://www.google.pt/
${BROWSER}                  firefox
${DELAY}                    0
${FF_PROFILE}               C:/ff_profile

*** Keywords ***

Open Browser To Google
    Open Browser  ${SERVER}  ${BROWSER}  ff_profile_dir=${FF_PROFILE}
    Maximize Browser Window
    Set Selenium Speed  ${DELAY}

When run, your test will now use this firefox profile with the proxy settings correctly configured. Of course this method is limited to Firefox. Running through other browsers will pick up the system network configuration anyway so this shouldn't be an issue.

Share:
14,458
Hélder Gonçalves
Author by

Hélder Gonçalves

Software Engineer with interest in .Net, C# and PL/SQL.

Updated on June 04, 2022

Comments

  • Hélder Gonçalves
    Hélder Gonçalves almost 2 years

    Ok so I got this code:

    ${SERVER}                   http://www.google.pt/
    ${BROWSER}                  firefox
    ${DELAY}                    0
    
    *** Keywords ***
    
    Open Browser To Google
        Open Browser  ${SERVER}  ${BROWSER}
        Maximize Browser Window
        Set Selenium Speed  ${DELAY}
    

    After I run the keywords "Open Browser To Google", firefox opens and can't even open the url. I figured I'm missing my work office's proxy to access the external network. How can i configure the firefox webdriver to open with a proxy (being system-default)?

    Ty

  • vascobnunes
    vascobnunes over 10 years
    I'm doing this, but ff requests username and password... It's boring to have to input those everytime i run a test... How do I overcome this?