Robot Framework - 使用系统代理运行Firefox [英] Robot Framework - Run Firefox with system proxy

查看:845
本文介绍了Robot Framework - 使用系统代理运行Firefox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

***关键字***

打开浏览器到Google
打开浏览器$ {服务器} $ {BROWSER}
最大化浏览器窗口
设置硒速度$ {DELAY}

运行关键字打开浏览器到Google后,Firefox会打开,甚至无法打开网址。
我想我错过了我的办公室的代理访问外部网络。
如何配置firefox webdriver使用代理(系统默认)打开?



Ty

1-创建Firefox个人资料

启动个人资料管理员



$ ul
  • firefox.exe -P (Windows)


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


  • ./ firefox -profilemanager (Linux)


    创建一个新的配置文件(保存到一个已知的位置)。打开配置文件并打开选项对话框,高级选项卡。选择网络并根据需要设置代理设置。关闭选项和Firefox。

    2在测试中指定Firefox配置文件

      $ {SERVER} http://www.google.pt/ 
    $ {BROWSER} firefox
    $ {DELAY} 0
    $ {FF_PROFILE} C: / ff_profile
    $ b ***关键字***

    打开浏览器到Google
    打开浏览器$ {SERVER} $ {BROWSER} ff_profile_dir = $ {FF_PROFILE}
    最大化浏览器窗口
    设置硒速度$ {DELAY}

    运行时,测试现在将使用此Firefox配置文件与正确配置的代理设置。当然这个方法仅限于Firefox。通过其他浏览器运行,无论如何将采取系统网络配置,所以这不应该是一个问题。


    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

    解决方案

    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.

    这篇关于Robot Framework - 使用系统代理运行Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆