您的位置:首页 > 其它

webdriver 设置代理

2016-04-14 15:01 246 查看
在 做selenium自动化测试的时候遇到浏览器打不开指定网页 这个情况下需要设置代理:

代码如下:

System.setProperty("webdriver.firefox.bin","E:\\asiaInfo\\firefox\\firefox.exe");//启动浏览器

//设置狐火浏览器代理:

FirefoxProfile profile = new FirefoxProfile();

//network.proxy.type", 1 这里的1代表手工设置

profile.setPreference("network.proxy.type", 1);

//network.proxy.http", "hzproxy.xxxx.com" 设置代理地址

profile.setPreference("network.proxy.http", "hzproxy.xxxx.com");

//network.proxy.http", "hzproxy.xxxx.com" 设置代理端口号

profile.setPreference("network.proxy.http_port", 8080);

driver = new FirefoxDriver(profile);

driver.manage().window().maximize();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: