Class: Blade::SauceLabsPlugin::WebDriver
- Inherits:
-
EventMachine::Completion
- Object
- EventMachine::Completion
- Blade::SauceLabsPlugin::WebDriver
- Defined in:
- lib/blade/sauce_labs_plugin/web_driver.rb
Instance Attribute Summary collapse
-
#capabilities ⇒ Object
readonly
Returns the value of attribute capabilities.
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #get_cookie(name) ⇒ Object
-
#initialize(capabilities) ⇒ WebDriver
constructor
A new instance of WebDriver.
- #navigate_to(url) ⇒ Object
- #session_id ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(capabilities) ⇒ WebDriver
Returns a new instance of WebDriver.
13 14 15 16 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 13 def initialize(capabilities) super() @capabilities = capabilities end |
Instance Attribute Details
#capabilities ⇒ Object (readonly)
Returns the value of attribute capabilities.
10 11 12 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 10 def capabilities @capabilities end |
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
11 12 13 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 11 def driver @driver end |
Instance Method Details
#active? ⇒ Boolean
34 35 36 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 34 def active? completed? end |
#get_cookie(name) ⇒ Object
66 67 68 69 70 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 66 def (name) if active? && = driver.manage.(name.to_s) [:value] end end |
#navigate_to(url) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 38 def navigate_to(url) EM.defer do begin driver.navigate.to(url) start = Time.now EM.tick_loop do if driver.current_url == url yield true :stop elsif Time.now - start > 2 yield false :stop end end rescue yield false end end end |
#session_id ⇒ Object
60 61 62 63 64 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 60 def session_id if active? driver.session_id end end |
#start ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 18 def start EM.defer do if @driver = get_driver succeed else fail end end end |
#stop ⇒ Object
28 29 30 31 32 |
# File 'lib/blade/sauce_labs_plugin/web_driver.rb', line 28 def stop EM.defer do yield(quit_driver) end end |