selenium/watir-webdriver远程启动目标机器运行脚本

2013-06-05  刘俊 

实验了一下,留在这里做个记录:
首先需要下载个jar包,在目标机器启动,作为master-client之间通讯用,下载地址:
http://code.google.com/p/selenium/downloads/list  #下载jar和IEdriver.exe
http://code.google.com/p/chromedriver/downloads/list  #下载chromedriver.exe
 
放在ruby的bin目录下或者放到system32目录下。
在client启动jar包。
 
require 'watir-webdriver'
#普通远程方式
b = Watir::Browser.new :remote, :desired_capabilities => :chrome, :url => "http://192.168.96.75:4444/wd/hub"   #96.75是我的client机器IP
 
#如果要走代理
caps = Selenium::WebDriver::Remote::Capabilities.chrome(:proxy => Selenium::WebDriver::Proxy.new(:http => "192.168.80.20:8080"))
driver = Selenium::WebDriver.for(:remote, :desired_capabilities => caps,:url => "http://192.168.96.75:4444/wd/hub")
 
#如果需要加配置
profile = Selenium::WebDriver::Chrome::Profile.new
profile
['download.prompt_for_download'] = false
profile
['download.default_directory'] = "c:/download"

driver
= Selenium::WebDriver.for :chrome, :profile => profile 
 
其他教程网上一大堆,就不一一列举了。
652°/6525 人阅读/0 条评论 发表评论

登录 后发表评论