Class: BsPlus::Browser
- Includes:
- Hashie::Extensions::Dash::IndifferentAccess
- Defined in:
- lib/bs_plus/browser.rb
Constant Summary collapse
- FileCache =
ActiveSupport::Cache::FileStore.new "#{Dir.home}/.browserstack_plus/cache"
- Popular =
[ new({browser: 'ie', browser_version: '7.0', os: 'Windows', os_version: 'XP'}), ]
- IEs =
all.select {|e| e.browser[/ie/i]}
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.all ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/bs_plus/browser.rb', line 21 def self.all FileCache.fetch('browser.list', expires_in: 24.hours) { @list ||= RestClient.get("https://#{Config.fetch(:username)}:#{Config.fetch(:password)}"\ "@www.browserstack.com/automate/browsers.json"). tap! {|e| JSON.parse e}. map {|e| new e}} end |
Instance Method Details
#snapshot(url) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bs_plus/browser.rb', line 36 def snapshot url # Input capabilities caps = Selenium::WebDriver::Remote::Capabilities.new.tap {|c| self.stringify_keys.select{|k,v| v}.each {|k,v| c[k] = v} c["browserstack.debug"] = "true" c["name"] = "Running BrowserStack from command line" } driver = Selenium::WebDriver.for(:remote, url: "https://#{Config.fetch(:username)}:#{Config.fetch(:password)}"\ "@hub.browserstack.com/wd/hub", desired_capabilities: caps) puts "Starting #{self}" driver.navigate.to url puts "Reached #{driver.title} from #{self}, saving screenshot" driver.save_screenshot(file = CGI.escape("#{url}__#{self}.png")) driver.quit puts "Done #{self}" Launchy.open "./#{file}" end |
#to_s ⇒ Object
58 59 60 61 |
# File 'lib/bs_plus/browser.rb', line 58 def to_s "#{browser}#{browser_version}"\ "(#{os}-#{os_version}#{':' + device if device})" end |