use*_*993 3 ruby proxy selenium phantomjs
我正在尝试使用PhantomJS 1.9.1在selenium webdriver(2.25)的ruby(1.8.7)脚本中配置代理.
我在Firefox上看到了一些例子,我用这个浏览器成功地完成了它.我用过这段代码:
profile = Selenium::WebDriver::Firefox::Profile.new
profile.proxy = Selenium::WebDriver::Proxy.new :ssl => 'chronos.landebitel.local:3128'
$browser = Watir::Browser.new :firefox, :profile => profile
Run Code Online (Sandbox Code Playgroud)
但我找不到任何phantomjs的例子.我搜索并尝试了许多解决方案,但都没有效果.
有人可以举个例子来帮助我吗?
尝试:
Watir::Browser.new( :phantomjs,
args: '--proxy=localhost:8181'
)
Run Code Online (Sandbox Code Playgroud)
小智 6
除了将代理传递给phantomjs之外,如果代理需要身份验证,您还可以传递用户名和密码.只需将所需选项作为字符串数组传递.
值得注意的是phantomjs以这种方式支持代理身份验证,并且chromedriver没有(截至2013年7月); 它要求您将身份验证输入到交互式UI中.
switches = ['--proxy=69.106.88.7:60199', '--proxy-auth=username:password123']
browser = Watir::Browser.new :phantomjs, :args => switches
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3913 次 |
| 最近记录: |