Running Watir webdriver scripts in Browser Stack Environment
Why it is required?:
If we need to run the scripts in more than 5 machines with different OS and browser versions then we may need to invest more in infrasturure. To aviod this, we will have Test server in Browserstack.
1. Create trail account in http://www.browserstack.com/
2. Copy the Authentication URL from your acoutn page
3. Run the below code
require ‘rubygems’
require ‘watir-webdriver’
include Selenium
caps = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
caps.platform = :WINDOWS
caps[:name] = “Watir WebDriver”
caps[:browser] = “chrome”
caps.version = 20
caps[“browserstack.debug”] = “true”
caps[“browserstack.tunnel”] = true
browser = Watir::Browser.new(:remote,
:url => “PASTE BTASCK URL HERE”, # Sample http://raveendran:x6XqqrJzJ9gUZ7sr@hub.browserstack.com/wd/hub
:desired_capabilities => caps)
browser.goto “http://google.com/”
sleep 9 # You should use wait methods instead of sleep
puts browser.title
browser.quit
Pros:
Easy implementation with any exisitng framework
Cons:
The execution speed will be 2x~3x slow when comparing with your local machine execution.