Module: AxeCapybara

Defined in:
lib/axe-capybara.rb

Class Method Summary collapse

Class Method Details

.configure(browser = :firefox) {|config| ... } ⇒ Object

configure method

  • which takes an optional argument browser

  • and a configuration block optional for Axe

Yields:

  • (config)


9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/axe-capybara.rb', line 9

def self.configure(browser = :firefox)
  # instantiate axe configuration (singleton) with defaults or given config
  if !block_given?
    raise Exception.new "Please provide a configure block for AxeCapybara"
  end

  config = Axe::Configuration.instance

  config.page = set_driver(browser)

  # await and return
  yield config
  config
end

.set_driver(browserSymbol) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/axe-capybara.rb', line 26

def self.set_driver(browserSymbol)
  if browserSymbol == :chrome
    Capybara.default_driver = :selenium_chrome
    Capybara.javascript_driver = :selenium_chrome
  else
    Capybara.default_driver = :selenium
    Capybara.javascript_driver = :selenium
  end
  Capybara::Selenium::Driver.new(nil, :browser => browserSymbol)
end