Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Proxy : Robot Framework and Firefox

I am trying to use a proxy of LocalHost and port 8080. I have written the following code in Robot Framework but the IP is not changing once the browser opens:

*** Settings ***
Documentation           This is a simple test with Robot Framework
Library                 Selenium2Library


*** Variables ***
${SERVER}                   http:/demo.testfire.net
${BROWSER}                  firefox
${DELAY}                    0



*** Keywords ***

Open Browser To Demo       
${proxy}=      Evaluate     sys.modules['selenium.webdriver'].Proxy()  sys, selenium.webdriver
${proxy.http_proxy}=         Set Variable  localhost:8080
Create Webdriver  Firefox       proxy=${proxy}
Go To  ${Server}


*** Test Cases ***
Valid Login
    Open Browser To Demo

Can anyone give me a fix to this so that IP address in Firefox changes to 127.0.0.1 without using Firefox Profiles?

like image 614
ParanoidPath Avatar asked Dec 07 '25 05:12

ParanoidPath


1 Answers

The example code in the Selenium2Library documentation was also not working for me, so I wrote this to start firefox with a proxy without setting up a whole new profile.

*** Settings ***
Library  Collections

*** Keywords ***
Open firefox browser with proxy  
    ${caps}=  Evaluate  sys.modules['selenium.webdriver'].DesiredCapabilities.FIREFOX  sys, selenium.webdriver
    ${proxy}=  Create dictionary  proxyType=MANUAL  httpProxy=YOUR-PROXY-URL:PORT
    Set to dictionary  ${caps}  proxy=${proxy}
    Open Browser  browser=headlessfirefox  desired_capabilities=${caps}
like image 127
Guillaume Avatar answered Dec 08 '25 19:12

Guillaume



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!