Python 代理:机器人框架和Firefox
我正在尝试使用LocalHost和端口8080的代理。 我已经在Robot Framework中编写了以下代码,但一旦浏览器打开,IP不会改变:Python 代理:机器人框架和Firefox,python,python-3.x,robotframework,selenium2library,Python,Python 3.x,Robotframework,Selenium2library,我正在尝试使用LocalHost和端口8080的代理。 我已经在Robot Framework中编写了以下代码,但一旦浏览器打开,IP不会改变: *** Settings *** Documentation This is a simple test with Robot Framework Library Selenium2Library *** Variables *** ${SERVER} http
*** 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
有谁能给我一个解决方案,让Firefox中的IP地址在不使用Firefox配置文件的情况下更改为127.0.0.1?Selenium2库文档中的示例代码对我也不起作用,所以我写了这篇文章,用代理启动Firefox,而不用设置一个全新的配置文件
*** 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}