Last active
August 29, 2015 14:09
-
-
Save ku/de6cd3bf913b61905b35 to your computer and use it in GitHub Desktop.
browserstack automation
This file contains hidden or 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 'selenium-webdriver' | |
# http://stackoverflow.com/a/16416941/2406748 | |
#profile = Selenium::WebDriver::Chrome::Profile.new | |
#profile["intl.accept_languages"] = "ja" | |
# Input capabilities | |
#caps = Selenium::WebDriver::Remote::Capabilities.chrome( | |
# 'chrome.profile' => profile.as_json['zip'] | |
#) | |
caps = Selenium::WebDriver::Remote::Capabilities.chrome | |
caps["chromeOptions"] = {} | |
caps["chromeOptions"]["args"] = ["--lang=ja"] | |
caps["browser"] = "firefox" | |
caps["browser_version"] = "32.0" | |
#caps["browser"] = "IE" | |
#caps["browser_version"] = "10.0" | |
caps["browser"] = "chrome" | |
caps["browser_version"] = "21.0" | |
caps["os"] = "Windows" | |
caps["win_res"] = "1024x768" | |
caps["resolution"] = "1024x768" | |
caps["name"] = "Testing Selenium 2 with Ruby on BrowserStack" | |
driver = Selenium::WebDriver.for( | |
:remote, | |
:url => "http://kaizenplatformin:[email protected]/wd/hub", | |
:desired_capabilities => caps, | |
) | |
caps = Selenium::WebDriver::Remote::Capabilities.chrome( | |
platform: "Linux", | |
version: "", | |
) | |
u = 'http://ido.nu/test.html' | |
u = 'http://tha.jp/' | |
u = 'http://www.google.com/' | |
u = 'http://www.softbank.jp/mobile/products/list/aquos-crystal/' | |
wait_sec = 5 | |
distjs_url = 'http://ido.nu/e.js' | |
puts "loading #{u}..." | |
driver.navigate.to u | |
puts "insert #{distjs_url}" | |
#driver.execute_script("setTimeout(function(){var d=document;var s=d.createElement('script');s.setAttribute('src','" + distjs_url + "');s.setAttribute('id','x');d.body.appendChild(s);}, 10)") | |
#driver.execute_script("setTimeout(function(){var d=document;var s=d.createElement('div');s.setAttribute('id','webdriver-wait-hint');d.body.appendChild(s);}, " + wait_sec.to_s + " * 1000)") | |
#wait = Selenium::WebDriver::Wait.new(:timeout => wait_sec * 1.2) # seconds | |
#wait.until { driver.find_element(:id => "webdriver-wait-hint") } | |
driver.save_screenshot("cool_vimeo.png") | |
puts driver.title | |
driver.quit |
This file contains hidden or 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
source 'https://rubygems.org' | |
gem 'selenium-webdriver' |
This file contains hidden or 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
GEM | |
remote: https://rubygems.org/ | |
specs: | |
childprocess (0.5.5) | |
ffi (~> 1.0, >= 1.0.11) | |
ffi (1.9.6) | |
multi_json (1.10.1) | |
rubyzip (1.1.6) | |
selenium-webdriver (2.44.0) | |
childprocess (~> 0.5) | |
multi_json (~> 1.0) | |
rubyzip (~> 1.0) | |
websocket (~> 1.0) | |
websocket (1.2.1) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
selenium-webdriver |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment