java+selenium学习汇总

1.Selenium与firefox对应版本
查询firefox版本步骤:
1.打开火狐浏览器。
2.在浏览器右上方找到“三”的图标。
3.选择下方的“问号”按钮,即帮助菜单。
4.然后选取“关于firefox”。
5.弹出窗口就能看到版本信息。
【Selenium】 -> 【FireFox】
2.25.0 -> 18
2.30.0 -> 19
2.31.0 -> 20
2.42.2 -> 29
2.44.0 -> 33 (不支持31)
2.53.0 -> 43,46(不支持47)
2.41.0 -> 26(绿色版本)
2.44 -> 32.0-35.0
2.53.0-2.53.6 -> 40.0.3(本司目前使用selenium和firefox版本)
selenium各版本jar包下载地址
http://selenium-release.storage.googleapis.com/index.html

2.java+selenium+firefox 设置代理更换代理
FirefoxProfile profile = new FirefoxProfile();
System.setProperty(“webdriver.firefox.bin”, “F:\fx\Mozilla Firefox\firefox.exe”);
profile.setPreference(“network.proxy.type”, 1); #默认值0,就是直接连接;1就是手工配置代理。
profile.setPreference(“network.proxy.http”, “ip”);
profile.setPreference(“network.proxy.http_port”, port);
FirefoxDriver driver = new FirefoxDriver(profile);
driver.get(“http://baidu.com”);

3.Java+selenium+phantomjs 更换代理
String url = “http://web.b.ebscohost.com/;
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
// 驱动支持(第二参数表明的是你的phantomjs引擎所在的路径,使用whereis phantomjs可以查看)
capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
“F:\phantomjs-2.1.1-windows\bin\phantomjs.exe”);
String proxyIpAndPort = “ip:port”;
Proxy proxy = new Proxy();
proxy.setHttpProxy(proxyIpAndPort).setFtpProxy(proxyIpAndPort).setSslProxy(proxyIpAndPort);
capabilities.setCapability(CapabilityType.ForSeleniumServer.AVOIDING_PROXY, true);
capabilities.setCapability(CapabilityType.ForSeleniumServer.ONLY_PROXYING_SELENIUM_TRAFFIC, true);

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值