Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 代理:机器人框架和Firefox_Python_Python 3.x_Robotframework_Selenium2library - Fatal编程技术网

Python 代理:机器人框架和Firefox

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

我正在尝试使用LocalHost和端口8080的代理。 我已经在Robot Framework中编写了以下代码,但一旦浏览器打开,IP不会改变:

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