selenium2如何设置firefox的UA

最近再做robot自动测试系统,使用的是selenium2library库,原因是在网上查找发现其能设置各个浏览器的UA进行手机端模拟测试,在google上查到了可以配置chrome的UA:http://stackoverflow.com/questions/21155750/how-do-i-modify-google-chrome-user-agent-string-with-robot-framework ,但是蛋疼的是竟然找不到设置firefox的,只能自己硬着头皮查阅文档来看了,几个小时过去终于有结果。

参考的文档:

http://code.google.com/p/selenium/wiki/TipsAndTricks

http://selenium.googlecode.com/git/docs/api/py/api.html

http://rtomac.github.io/robotframework-selenium2library/doc/Selenium2Library.html#Create Webdriver

关键字可以这么写:

${ffprofile}=    Evaluate sys.modules['selenium.webdriver.firefox.firefox_profile'].FirefoxProfile()      sys, selenium.webdriver.firefox.firefox_profile
Call Method    ${ffprofile}    set_preference     general.useragent.override     Mozilla/4.0 (compatible; MSIE 4.01; Windows CE; .NET CLR 2.0.50727)/UCWEB8.0.3.99/31/999
Create WebDriver Firefox firefox_profile=${ffprofile}
Go To http://www.baidu.com/

OK了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值