Class: CloudTest::Browserstack
- Defined in:
- lib/cloud_test/browserstack.rb
Constant Summary collapse
- SERVER =
do anything browserstack specific
"hub-cloud.browserstack.com/wd/hub"
- ENV_USER =
'BROWSERSTACK_USERNAME'
- ENV_PWD =
'BROWSERSTACK_ACCESS_KEY'
- DASHBOARD_LINK =
"https://automate.browserstack.com/dashboard"
- REST_STATUS_SERVER =
"https://api.browserstack.com/automate/sessions/"
Constants inherited from Core
Class Method Summary collapse
- .check_session_id(session_id) ⇒ Object
-
.get_all_caps ⇒ Object
dry run.
- .get_status_msg(failed, reason) ⇒ Object
- .init(config = nil) ⇒ Object
-
.list_caps ⇒ Object
defaults.
- .start ⇒ Object
Methods inherited from Core
check_if_input_is_valid?, copy_keys, get_default_caps, get_provider_class, list_dashboard_link, list_these_caps, load_config, merge_caps, register_driver, upload_status
Class Method Details
.check_session_id(session_id) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/cloud_test/browserstack.rb', line 70 def self.check_session_id(session_id) unless session_id =~ Regexp.new('^[0-9a-z]{40}$') puts session_id << "length: " << session_id.length raise "session_id is invalid!" end end |
.get_all_caps ⇒ Object
dry run
57 58 59 60 61 |
# File 'lib/cloud_test/browserstack.rb', line 57 def self.get_all_caps # dry run @caps.kind_of?(Hash) || init() puts "Capabilities: " Core.list_these_caps(@caps) end |
.get_status_msg(failed, reason) ⇒ Object
63 64 65 66 67 68 |
# File 'lib/cloud_test/browserstack.rb', line 63 def self.get_status_msg(failed, reason) { "status" => failed ? "passed" : "failed", "reason" => reason } end |
.init(config = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/cloud_test/browserstack.rb', line 12 def self.init(config=nil) @config = config || Core.load_config(ENV_USER, ENV_PWD) @caps = Core.get_default_caps @caps["browserstack.local"] = true @caps["browserstack.debug"] = true # Visual log @caps['os_version'] = '10' @caps['os'] = 'WINDOWS' @caps['browser'] = 'CHROME' @caps = Core.merge_caps(@caps, @config, 'browserstack') Capybara.app_host = "http://127.0.0.1:38946" Capybara.server_port = 38946 if !config.nil? start() end end |
.list_caps ⇒ Object
defaults
49 50 51 52 53 54 55 |
# File 'lib/cloud_test/browserstack.rb', line 49 def self.list_caps # defaults Core.list_caps puts "Browserstack specific defaults:" puts "\tbrowserstack.local: true" puts "\tbrowserstack.debug: true " puts 'you can generate capabilities here https://www.browserstack.com/automate/capabilities?tag=selenium-2-3' end |
.start ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/cloud_test/browserstack.rb', line 30 def self.start puts '> Running features on browserstack.com' begin require 'browserstack/local' rescue LoadError puts 'Please add gem "browserstack-local" to your gemfile!' raise LoadError end # Code to start browserstack local (tunnel) before start of test @bs_local = BrowserStack::Local.new bs_local_args = {"key" => "#{@config['key']}", "logfile" => "log/browserstack-local-logs.log"} @bs_local.start(bs_local_args) register_driver(@caps, @config['user'], @config['key'], SERVER) # Code to stop browserstack local after end of test at_exit do @bs_local.stop unless @bs_local.nil? end end |