This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'highline/import' | |
require 'watir-webdriver' | |
begin | |
username = ask("What is your twitter username?") | |
password = ask("and your password?") { |q| q.echo = false } | |
browser= Watir::Browser.start "twitter.com", :firefox | |
browser.span(:text => "Sign in").click | |
browser.text_field(:id => "username").set username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'watir-webdriver' # gem install watir-webdriver | |
require 'rspec' # gem install rspec | |
class BrowserContainer | |
attr_reader :browser | |
def initialize(browser) | |
@browser = browser | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir-webdriver' | |
def search_field browser | |
browser.text_field(:name => "q") | |
end | |
browser = Watir::Browser.new :firefox | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WatirSpec guards for this implementation: | |
not_compliant : {:file=>"/Users/alscott/Projects/watir-webdriver/spec/watirspec/browser_spec.rb:53:in `block (2 levels) in <top (required)>'"} | |
bug : {:file=>"/Users/alscott/Projects/watir-webdriver/spec/watirspec/element_spec.rb:104:in `block (2 levels) in <top (required)>'", :key=>"http://code.google.com/p/selenium/issues/detail?id=157"} | |
not_compliant : {:file=>"/Users/alscott/Projects/watir-webdriver/spec/watirspec/browser_spec.rb:84:in `block (2 levels) in <top (required)>'"} | |
deviates : {:file=>"/Users/alscott/Projects/watir-webdriver/spec/watirspec/browser_spec.rb:95:in `block (2 levels) in <top (required)>'"} | |
not_compliant : {:file=>"/Users/alscott/Projects/watir-webdriver/spec/watirspec/div_spec.rb:185:in `block in <top (required)>'"} | |
not_compliant : {:file=>"/Users/alscott/Projects/watir-webdriver/spec/watirspec/image_spec.rb:127:in `block in <top (required)>'"} | |
not_compliant : {:file=>"/Users/als |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'selenium-webdriver' | |
require "benchmark" | |
d = Selenium::WebDriver.for :firefox | |
d.navigate.to "file:///#{Dir.pwd}/test.html" | |
e = d.find_element(:id => "q") | |
TESTS = 30 | |
Benchmark.bmbm do |results| | |
results.report("clear + send_keys:") { TESTS.times { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'selenium-webdriver' | |
require "benchmark" | |
profile = Selenium::WebDriver::Firefox::Profile.new | |
profile.native_events = false | |
d = Selenium::WebDriver.for :firefox, :profile => profile | |
d.navigate.to "file:///#{Dir.pwd}/test.html" | |
e = d.find_element(:id => "q") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'thread' | |
require 'watir-webdriver' | |
def test_google | |
3.times do | |
browser = Watir::Browser.start 'http://www.etsy.com', :chrome | |
browser.text_field(:name, 'search_query').set 'hat' | |
start_time = Time.now | |
browser.button(:text, 'Search').click | |
end_time = Time.now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user system total real | |
selenium-webdriver 1.820000 0.830000 24.010000 ( 67.492727) | |
watir-webdriver 1.850000 0.840000 24.200000 ( 64.550630) | |
capybara 1.810000 0.830000 25.160000 ( 69.461563) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'watir-webdriver' | |
require 'nokogiri' | |
require 'bench' | |
Watir::always_locate = false | |
b = Watir::Browser.start "http://www.expedia.com/Flights-Search?trip=oneway&leg1=from:SEA,to:SFO,departure:11%2F11%2F2012TANYT&passengers=children:0,adults:1,seniors:0,infantinlap:Y&options=cabinclass:coach,nopenalty:N,sortby:price&mode=search" | |
prices = [] | |
benchmark 'code' do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rspec' | |
require 'watir-webdriver' | |
browser = Watir::Browser.new | |
RSpec.configure do |config| | |
config.before(:each) { @browser = browser } | |
config.after(:suite) { browser.close unless browser.nil? } | |
end |
OlderNewer