在 做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();
本文介绍如何使用Selenium为Firefox浏览器设置HTTP代理,包括配置代理地址及端口的方法。
195

被折叠的 条评论
为什么被折叠?



