Module: SeleniumPlus

Defined in:
lib/selenium_plus.rb,
lib/selenium_plus/driver.rb,
lib/selenium_plus/finders.rb,
lib/selenium_plus/version.rb,
lib/selenium_plus/exceptions.rb,
lib/selenium_plus/page_obj/page.rb,
lib/selenium_plus/selenium/dlist.rb,
lib/selenium_plus/selenium/table.rb,
lib/selenium_plus/page_obj/iframe.rb,
lib/selenium_plus/selenium/select.rb,
lib/selenium_plus/page_obj/section.rb,
lib/selenium_plus/page_obj/container.rb

Defined Under Namespace

Modules: Container, Elements, Exceptions, Finders Classes: Driver, Iframe, Page, Section

Constant Summary collapse

VERSION =
'0.0.9'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.current_driverSymbol

The name of the driver currently in use

Returns:

  • (Symbol)


82
83
84
# File 'lib/selenium_plus.rb', line 82

def current_driver
  @current_driver
end

.default_driverSymbol

The name of default driver

Returns:

  • (Symbol)


75
76
77
# File 'lib/selenium_plus.rb', line 75

def default_driver
  @default_driver
end

.default_wait_timeObject

Returns the value of attribute default_wait_time.



33
34
35
# File 'lib/selenium_plus.rb', line 33

def default_wait_time
  @default_wait_time
end

.driverObject

Returns the value of attribute driver.



33
34
35
# File 'lib/selenium_plus.rb', line 33

def driver
  @driver
end

.enable_highlight_elementObject

Returns the value of attribute enable_highlight_element.



33
34
35
# File 'lib/selenium_plus.rb', line 33

def enable_highlight_element
  @enable_highlight_element
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Configure SeleniumPlus

Examples:

SeleniumPlus.configure do |config|
  config.default_wait_time  = 10
  config.enable_highlight   = true
end
default_wait_time = Integer
enable_highlight_element = Boolean

Yields:

  • (_self)

Yield Parameters:

  • _self (SeleniumPlus)

    the object that the method was called on



46
47
48
# File 'lib/selenium_plus.rb', line 46

def configure
  yield self
end

.driversArray

All register drivers

Returns:

  • (Array)


68
69
70
# File 'lib/selenium_plus.rb', line 68

def drivers
  @drivers ||= {}
end

.register_driver(name) { ... } ⇒ Object

Register a new driver for SeleniumPlus

Example:

SeleniumPlus.register_driver :chrome_driver do
  SeleniumPlus::Driver.new(:browser => :chrome)
end

Parameters:

  • name (Symbol)

    The name of the new driver

Yields:

  • A block executed in the context of the new Driver

Returns:

  • nothing



61
62
63
# File 'lib/selenium_plus.rb', line 61

def register_driver(name, &block)
  drivers[name] = block
end

.use_default_driverObject

Use the default driver as the current driver



88
89
90
# File 'lib/selenium_plus.rb', line 88

def use_default_driver
  @current_driver = nil
end

.using_driver(driver) ⇒ Object



92
93
94
95
96
97
98
99
100
# File 'lib/selenium_plus.rb', line 92

def using_driver(driver)
  unless drivers.has_key?(driver)
    other_drivers = drivers.keys.map { |key| key.inspect }
    raise SeleniumPlus::Exceptions::DriverNotFoundError, "Driver #{driver} was not found. Available types: #{other_drivers.join(', ')}"
  end
  if @driver.nil? || @driver.native.browser != driver
    @driver = drivers[driver].call
  end
end