Method: Oats::Locator#initialize
- Defined in:
- lib/oats/oats_selenium_api.rb
#initialize(locator, ehow = nil) ⇒ Locator
Returns a new instance of Locator.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/oats/oats_selenium_api.rb', line 23 def initialize(locator, ehow=nil) if locator.instance_of?(Array) @ehow = locator[1] @what = locator[0] elsif locator.instance_of?(String) @what = @locator = locator if ehow @ehow = ehow else if locator[0,5] == 'link=' @what = locator[5..-1] @ehow = :link elsif locator[0,5] == 'name=' @what = locator[5..-1] @ehow = :name elsif locator[0,3] == 'id=' @what = locator[3..-1] @ehow = :id elsif locator.index('/') @ehow = :xpath else @ehow = :name end end else raise('Unexpected arguments') end end |