2011-06-29 01:05:07 +00:00
|
|
|
module HtmlSelectorsHelpers
|
|
|
|
# Maps a name to a selector. Used primarily by the
|
|
|
|
#
|
|
|
|
# When /^(.+) within (.+)$/ do |step, scope|
|
|
|
|
#
|
|
|
|
# step definitions in web_steps.rb
|
|
|
|
#
|
|
|
|
def selector_for(locator)
|
|
|
|
case locator
|
|
|
|
|
2012-03-01 10:07:22 +00:00
|
|
|
when 'the page'
|
|
|
|
'html > body'
|
|
|
|
|
|
|
|
when 'the main form'
|
|
|
|
'form.formtastic'
|
|
|
|
|
|
|
|
when 'the dialog popup'
|
|
|
|
'.ui-dialog'
|
|
|
|
|
|
|
|
when 'the list of entries'
|
|
|
|
'li.input.relationship'
|
2011-09-17 14:23:43 +00:00
|
|
|
|
|
|
|
when 'the role'
|
|
|
|
'.role'
|
2012-03-01 10:07:22 +00:00
|
|
|
|
|
|
|
when 'the submit button'
|
|
|
|
'form.formtastic #local-actions-bottom-bar input[type=submit]'
|
|
|
|
|
2011-06-29 01:05:07 +00:00
|
|
|
# Add more mappings here.
|
|
|
|
# Here is an example that pulls values out of the Regexp:
|
|
|
|
#
|
|
|
|
# when /^the (notice|error|info) flash$/
|
|
|
|
# ".flash.#{$1}"
|
|
|
|
|
|
|
|
# You can also return an array to use a different selector
|
|
|
|
# type, like:
|
|
|
|
#
|
|
|
|
# when /the header/
|
|
|
|
# [:xpath, "//header"]
|
|
|
|
|
|
|
|
# This allows you to provide a quoted selector as the scope
|
|
|
|
# for "within" steps as was previously the default for the
|
|
|
|
# web steps:
|
|
|
|
when /^"(.+)"$/
|
|
|
|
$1
|
|
|
|
|
|
|
|
else
|
|
|
|
raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
|
|
|
|
"Now, go and add a mapping in #{__FILE__}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
World(HtmlSelectorsHelpers)
|