Robot Framework - Run Firefox with system proxy

我们两清 提交于 2019-12-10 11:27:07

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/16462894/robot-framework-run-firefox-with-system-proxy

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