Use custom selectors in within methods

This continues the centralization of XPath generation
and failure messages.
This commit is contained in:
Adam McCrea 2011-08-27 17:57:12 -04:00 committed by Anders Törnqvist and Kim Burgestrand
parent fd7cf4a4bc
commit ea8463c010
2 changed files with 6 additions and 2 deletions

View File

@ -100,6 +100,10 @@ Capybara.add_selector(:field) do
xpath { |locator, options| XPath::HTML.field(locator) }
end
Capybara.add_selector(:fieldset) do
xpath { |locator, options| XPath::HTML.fieldset(locator) }
end
Capybara.add_selector(:link_or_button) do
xpath { |locator, options| XPath::HTML.link_or_button(locator) }
failure_message { |node, selector| "no link or button '#{selector.locator}' found" }

View File

@ -203,7 +203,7 @@ module Capybara
# @param [String] locator Id or legend of the fieldset
#
def within_fieldset(locator)
within :xpath, XPath::HTML.fieldset(locator) do
within :fieldset, locator do
yield
end
end
@ -215,7 +215,7 @@ module Capybara
# @param [String] locator Id or caption of the table
#
def within_table(locator)
within :xpath, XPath::HTML.table(locator) do
within :table, locator do
yield
end
end