Sha256: 79c144d4584257441ca64779b1cce218a726d660c8f317c326bf7875fd0e1be8

Contents?: true

Size: 742 Bytes

Versions: 6

Compression:

Stored size: 742 Bytes

Contents

require File.expand_path('../selectors/defaults', __FILE__)

def fsf(*args)
  selector        = sf(*args)
  selector_format = selector.starts_with?('.//') ? :xpath : :css

  page.find(selector_format, selector)
end

def idsf(*args)
  id_selector = sf(*args)
  id_selector.starts_with?('#') ? id_selector[1..-1] : id_selector
end

def sf(*args)
  selector_description = args[0]
  selector_entry       = Rspectacular.selectors.find { |regex, selector| selector_description.match regex }

  fail "Cannot find selector for '#{selector_description}'. Please add it to the list of selectors." if selector_entry.nil?

  selector             = selector_entry[1]

  if selector.respond_to? :call
    selector.call(*args)
  else
    selector
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rspectacular-0.59.0 lib/rspectacular/selectors.rb
rspectacular-0.58.0 lib/rspectacular/selectors.rb
rspectacular-0.57.0 lib/rspectacular/selectors.rb
rspectacular-0.56.0 lib/rspectacular/selectors.rb
rspectacular-0.55.0 lib/rspectacular/selectors.rb
rspectacular-0.54.0 lib/rspectacular/selectors.rb