在 selenium webdriver 中使用带有 phantomjs 的代理 [英] using a proxy with phantomjs in selenium webdriver

查看:72
本文介绍了在 selenium webdriver 中使用带有 phantomjs 的代理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 selenium webdriver (2.25) 的 ruby​​ (1.8.7) 脚本中使用 PhantomJS 1.9.1 配置代理.

I'm trying to configure a proxy with PhantomJS 1.9.1 in a ruby (1.8.7) script for selenium webdriver (2.25).

我在 Firefox 上看到了几个例子,我用这个浏览器成功地做到了.我使用了这个代码:

I saw a few examples with Firefox, and I successfully did it with this browser. I used this code :

profile = Selenium::WebDriver::Firefox::Profile.new
    profile.proxy = Selenium::WebDriver::Proxy.new :ssl => 'chronos.landebitel.local:3128'
    $browser = Watir::Browser.new :firefox, :profile => profile

但是我找不到 phantomjs 的任何示例.我搜索并尝试了很多解决方案,但没有一个奏效.

But I can't find any examples for phantomjs. I searched and tried many solutions, but none works.

有人可以举个例子来帮助我吗?

Can someone can give me an example to help me?

推荐答案

尝试:

Watir::Browser.new( :phantomjs,
    args: '--proxy=localhost:8181'
)

这篇关于在 selenium webdriver 中使用带有 phantomjs 的代理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆