mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Move button and link xpaths into XPath class
This commit is contained in:
parent
39081f3c7d
commit
75730ef137
2 changed files with 12 additions and 4 deletions
|
@ -138,12 +138,11 @@ module Capybara
|
|||
alias_method :field_labeled, :find_field
|
||||
|
||||
def find_link(locator)
|
||||
find("//a[@id='#{locator}' or contains(.,'#{locator}') or @title='#{locator}']")
|
||||
find(XPath.link(locator).to_s)
|
||||
end
|
||||
|
||||
def find_button(locator)
|
||||
button = find("//input[@type='submit' or @type='image'][@id='#{locator}' or @value='#{locator}']")
|
||||
button || find("//button[@id='#{locator}' or @value='#{locator}' or contains(.,'#{locator}')]")
|
||||
find(XPath.button(locator).to_s)
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -38,6 +38,15 @@ module Capybara
|
|||
def fieldset(locator)
|
||||
append("//fieldset[@id=#{s(locator)} or contains(legend,#{s(locator)})]")
|
||||
end
|
||||
|
||||
def link(locator)
|
||||
append("//a[@id=#{s(locator)} or contains(.,#{s(locator)}) or @title=#{s(locator)}]")
|
||||
end
|
||||
|
||||
def button(locator)
|
||||
xpath = append("//input[@type='submit' or @type='image'][@id=#{s(locator)} or @value=#{s(locator)}]")
|
||||
xpath.append("//button[@id=#{s(locator)} or @value=#{s(locator)} or contains(.,#{s(locator)})]")
|
||||
end
|
||||
|
||||
def text_field(locator)
|
||||
append("//input[@type='text'][@id=#{s(locator)} or @id=//label[contains(.,#{s(locator)})]/@for]")
|
||||
|
@ -71,7 +80,7 @@ module Capybara
|
|||
@paths.join(' | ')
|
||||
end
|
||||
|
||||
private
|
||||
protected
|
||||
|
||||
# Sanitize a String for putting it into an xpath query
|
||||
def s(string)
|
||||
|
|
Loading…
Reference in a new issue