Class: SpecialSauce::Capybara

Inherits:
Driver
  • Object
show all
Defined in:
lib/special_sauce/capybara.rb

Class Method Summary collapse

Methods inherited from Driver

auth?, authentication, browsers, current_browser_caps, desired_capabilities, sanitized_browser_options, sauce_endpoint, single_browser_caps

Class Method Details

.current_session(options = {}) ⇒ Object



4
5
6
7
8
9
# File 'lib/special_sauce/capybara.rb', line 4

def self.current_session(options = {})
  Kernel.warn(
    "SpecialSauce::Capybara#current_session is deprecated and will be removed in v1.0.0. Use 'setup_session' instead."
  )
  setup_session(options)
end

.setup_session(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/special_sauce/capybara.rb', line 11

def self.setup_session(options = {})
  unless auth?
    Kernel.warn(
      'Sauce Labs auth ENV variables not set ... skipping SpecialSauce::Capybara.setup_session'
    )
    return
  end

  ::Capybara.register_driver :special_sauce do |app|
    ::Capybara::Selenium::Driver.new(
      app,
      browser: :remote,
      url: sauce_endpoint,
      desired_capabilities: desired_capabilities(options)
    )
  end

  ::Capybara.current_driver = :special_sauce
  ::Capybara.javascript_driver = :special_sauce

  ::Capybara.current_session
end