mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Convert XPath to string in find method
This commit is contained in:
parent
75730ef137
commit
ec4687a7a4
1 changed files with 11 additions and 11 deletions
|
@ -38,25 +38,25 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def fill_in(locator, options={})
|
def fill_in(locator, options={})
|
||||||
field = find(XPath.fillable_field(locator).to_s)
|
field = find(XPath.fillable_field(locator))
|
||||||
raise Capybara::ElementNotFound, "cannot fill in, no text field, text area or password field with id or label '#{locator}' found" unless field
|
raise Capybara::ElementNotFound, "cannot fill in, no text field, text area or password field with id or label '#{locator}' found" unless field
|
||||||
field.set(options[:with])
|
field.set(options[:with])
|
||||||
end
|
end
|
||||||
|
|
||||||
def choose(locator)
|
def choose(locator)
|
||||||
field = find(XPath.radio_button(locator).to_s)
|
field = find(XPath.radio_button(locator))
|
||||||
raise Capybara::ElementNotFound, "cannot choose field, no radio button with id or label '#{locator}' found" unless field
|
raise Capybara::ElementNotFound, "cannot choose field, no radio button with id or label '#{locator}' found" unless field
|
||||||
field.set(true)
|
field.set(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check(locator)
|
def check(locator)
|
||||||
field = find(XPath.checkbox(locator).to_s)
|
field = find(XPath.checkbox(locator))
|
||||||
raise Capybara::ElementNotFound, "cannot check field, no checkbox with id or label '#{locator}' found" unless field
|
raise Capybara::ElementNotFound, "cannot check field, no checkbox with id or label '#{locator}' found" unless field
|
||||||
field.set(true)
|
field.set(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
def uncheck(locator)
|
def uncheck(locator)
|
||||||
field = find(XPath.checkbox(locator).to_s)
|
field = find(XPath.checkbox(locator))
|
||||||
raise Capybara::ElementNotFound, "cannot uncheck field, no checkbox with id or label '#{locator}' found" unless field
|
raise Capybara::ElementNotFound, "cannot uncheck field, no checkbox with id or label '#{locator}' found" unless field
|
||||||
field.set(false)
|
field.set(false)
|
||||||
end
|
end
|
||||||
|
@ -68,7 +68,7 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def attach_file(locator, path)
|
def attach_file(locator, path)
|
||||||
field = find(XPath.file_field(locator).to_s)
|
field = find(XPath.file_field(locator))
|
||||||
raise Capybara::ElementNotFound, "cannot attach file, no file field with id or label '#{locator}' found" unless field
|
raise Capybara::ElementNotFound, "cannot attach file, no file field with id or label '#{locator}' found" unless field
|
||||||
field.set(path)
|
field.set(path)
|
||||||
end
|
end
|
||||||
|
@ -107,13 +107,13 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def within_fieldset(locator)
|
def within_fieldset(locator)
|
||||||
within XPath.fieldset(locator).to_s do
|
within XPath.fieldset(locator) do
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def within_table(locator)
|
def within_table(locator)
|
||||||
within XPath.table(locator).to_s do
|
within XPath.table(locator) do
|
||||||
yield
|
yield
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -129,20 +129,20 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def find(locator)
|
def find(locator)
|
||||||
all(locator).first
|
all(locator.to_s).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_field(locator)
|
def find_field(locator)
|
||||||
find(XPath.field(locator).to_s)
|
find(XPath.field(locator))
|
||||||
end
|
end
|
||||||
alias_method :field_labeled, :find_field
|
alias_method :field_labeled, :find_field
|
||||||
|
|
||||||
def find_link(locator)
|
def find_link(locator)
|
||||||
find(XPath.link(locator).to_s)
|
find(XPath.link(locator))
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_button(locator)
|
def find_button(locator)
|
||||||
find(XPath.button(locator).to_s)
|
find(XPath.button(locator))
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Add table
Reference in a new issue