Add field doesn't need a block
This commit is contained in:
parent
6ce66edf6f
commit
34e064fa4c
|
@ -57,31 +57,31 @@ module Capybara
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_field(locator)
|
def text_field(locator)
|
||||||
add_field(locator) { |id| "//input[@type='text'][@id=#{id}]" }
|
add_field(locator, "//input[@type='text']")
|
||||||
end
|
end
|
||||||
|
|
||||||
def password_field(locator)
|
def password_field(locator)
|
||||||
add_field(locator) { |id| "//input[@type='password'][@id=#{id}]" }
|
add_field(locator, "//input[@type='password']")
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_area(locator)
|
def text_area(locator)
|
||||||
add_field(locator) { |id| "//textarea[@id=#{id}]" }
|
add_field(locator, "//textarea")
|
||||||
end
|
end
|
||||||
|
|
||||||
def radio_button(locator)
|
def radio_button(locator)
|
||||||
add_field(locator) { |id| "//input[@type='radio'][@id=#{id}]" }
|
add_field(locator, "//input[@type='radio']")
|
||||||
end
|
end
|
||||||
|
|
||||||
def checkbox(locator)
|
def checkbox(locator)
|
||||||
add_field(locator) { |id| "//input[@type='checkbox'][@id=#{id}]" }
|
add_field(locator, "//input[@type='checkbox']")
|
||||||
end
|
end
|
||||||
|
|
||||||
def select(locator)
|
def select(locator)
|
||||||
add_field(locator) { |id| "//select[@id=#{id}]" }
|
add_field(locator, "//select")
|
||||||
end
|
end
|
||||||
|
|
||||||
def file_field(locator)
|
def file_field(locator)
|
||||||
add_field(locator) { |id| "//input[@type='file'][@id=#{id}]" }
|
add_field(locator, "//input[@type='file']")
|
||||||
end
|
end
|
||||||
|
|
||||||
def scope(scope)
|
def scope(scope)
|
||||||
|
@ -102,10 +102,10 @@ module Capybara
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def add_field(locator)
|
def add_field(locator, field)
|
||||||
xpath = append(yield(s(locator)))
|
xpath = append("#{field}[@id=#{s(locator)}]")
|
||||||
xpath = xpath.append(yield("//label[contains(.,#{s(locator)})]/@for"))
|
xpath = xpath.append("#{field}[@id=//label[contains(.,#{s(locator)})]/@for]")
|
||||||
xpath.prepend(yield("//label[text()=#{s(locator)}]/@for"))
|
xpath.prepend("#{field}[@id=//label[text()=#{s(locator)}]/@for]")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sanitize a String for putting it into an xpath query
|
# Sanitize a String for putting it into an xpath query
|
||||||
|
|
Loading…
Reference in New Issue