Selenium学习笔记4

 Selenium RC server的一个重要启动参数是-firefoxProfileTemplate <dir>,这个参数用于指定firefox启动参数模板的路径,Firefox在启动浏览器时,会使用prefs.js文件获取参数,缺省位置在C:/Documents and Settings/cuikang/Application Data/Mozilla/Firefox/Profiles/,但实际上Selenium RC server在启动时缺省不使用任何参数,也就是说无法配置各种浏览器参数,比如代理服务器设置等等。

但我在使用Selenium RC server时,其实是想让它通过本地代理服务器访问外网,因为RPT(Rational performance tester)使用localhost:1080监听http请求和响应以录制测试脚本,所以我使用了自制的prefs.js来启动Firefox,启动Selenium RC server:

H:/selenium-remote-control-1.0-beta-2/selenium-server-1.0-beta-2>java -jar selen
ium-server.jar -firefoxProfileTemplate H:/selenium-remote-control-1.0-beta-2/sel
enium-server-1.0-beta-2/profiles/new -singleWindow

prefs.js文件内容:

user_pref("network.http.proxy.version", "1.0");
user_pref("network.proxy.no_proxies_on", "localhost,mozilla.com,sina.com.cn");
user_pref("network.proxy.socks", "localhost");
user_pref("network.proxy.socks_port", 1080);
user_pref("network.proxy.socks_version", 4);
user_pref("network.proxy.type", 1);

其中network.proxy.sock指定代理服务器host,network.proxy.socks_port指定代理端口,network.proxy.no_proxies_on指定哪些url不需要经过代理服务器,这个参数非常重要,因为Selenium RC server在启动firefox时会访问本地的文件,如果不过滤localhost等,那么RPT会录到很多无用的URL。

在selenium;论坛上有一个关于这个问题的经典帖子:http://clearspace.openqa.org/message/59891#59891

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值