Class: Teaspoon::Driver::BrowserStack
- Defined in:
- lib/teaspoon/driver/browserstack.rb
Constant Summary collapse
- MAX_PARALLEL =
10
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ BrowserStack
constructor
A new instance of BrowserStack.
- #run_specs(runner, url) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ BrowserStack
Returns a new instance of BrowserStack.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/teaspoon/driver/browserstack.rb', line 18 def initialize( = nil) ||= {} case when Hash then = .symbolize_keys when String then = JSON.parse().symbolize_keys else raise Teaspoon::DriverOptionsError.new(types: "hash or json string") end unless [:capabilities] && [:capabilities].is_a?(Array) raise Teaspoon::DriverOptionsError.new(types: "capabilities array." \ "Options must have a key 'capabilities' of type array") end [:capabilities].each(&:symbolize_keys!) rescue JSON::ParserError raise Teaspoon::DriverOptionsError.new(types: "hash or json string") end |
Instance Method Details
#run_specs(runner, url) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/teaspoon/driver/browserstack.rb', line 35 def run_specs(runner, url) parallelize do driver = Thread.current[:driver] driver.navigate.to(url) ::Selenium::WebDriver::Wait.new().until do done = driver.execute_script("return window.Teaspoon && window.Teaspoon.finished") driver.execute_script("return window.Teaspoon && window.Teaspoon.getMessages() || []").each do |line| runner.process("#{line}\n") end done end end end |