Ruby Selenium 用法

基本用法如下:

require "rubygems"
require "selenium-webdriver"

driver = Selenium::WebDriver.for(:ie);# 
driver.get("http://www.baidu.com");

element = driver.find_element(:name, "wd");
element.send_keys("Glacier");

element = driver.find_element(:id, "su");
element.send_keys("\n");

if $params['browser'] == 'Firefox'
    $driver = Selenium::WebDriver.for :firefox
end
if $params['browser'] == 'Chrome'
    $driver = Selenium::WebDriver.for :remote, :url => "http://localhost:44444/wd/hub", :desired_capabilities => :chrome
end
if $params['browser'] == 'IE'
    $driver = Selenium::WebDriver.for :ie
end

你可能感兴趣的:(Ruby,GEM,用法)