Use contains() instead of text()

This commit is contained in:
Jonas Nicklas and Kevin Fitzpatrick 2009-11-14 15:46:09 +01:00 committed by Jonas Nicklas
parent 0acee560a2
commit 90ea86ffd1
3 changed files with 4 additions and 4 deletions

View File

@ -31,7 +31,7 @@ class Webcat::Driver::RackTest
def select(option)
node.xpath(".//option").each { |node| node.remove_attribute("selected") }
node.xpath(".//option[text()='#{option}']").first["selected"] = 'selected'
node.xpath(".//option[contains(.,'#{option}')]").first["selected"] = 'selected'
end
def click

View File

@ -31,7 +31,7 @@ class Webcat::Driver::Selenium
end
def select(option)
node.find_element(:xpath, ".//option[text()='#{option}']").select
node.find_element(:xpath, ".//option[contains(.,'#{option}')]").select
end
def click

View File

@ -80,7 +80,7 @@ private
end
def find_link(locator)
link = find_element("//a[@id='#{locator}']", %{//a[text()="#{locator}"]}, %{//a[@title="#{locator}"]})
link = find_element("//a[@id='#{locator}']", "//a[contains(.,'#{locator}')]", "//a[@title='#{locator}']")
raise Webcat::ElementNotFound, "no button with value or id '#{locator}' found" unless link
link
end
@ -124,7 +124,7 @@ private
def find_field_by_label(locator, *kinds)
kinds.each do |kind|
label = find("//label[text()='#{locator}']").first
label = find("//label[contains(.,'#{locator}')]").first
if label
element = find_field_by_id(label[:for], kind)
return element if element