lib/watir-webdriver/locators/element_locator.rb in watir-webdriver-0.4.1 vs lib/watir-webdriver/locators/element_locator.rb in watir-webdriver-0.5.0
- old
+ new
@@ -195,18 +195,21 @@
selector
end
def normalize_selector(how, what)
case how
- when :tag_name, :text, :xpath, :index, :class, :for, :label
+ when :tag_name, :text, :xpath, :index, :class, :label
# include :class since the valid attribute is 'class_name'
# include :for since the valid attribute is 'html_for'
[how, what]
when :class_name
[:class, what]
when :caption
[:text, what]
+ when :for
+ assert_valid_as_attribute :html_for
+ [how, what]
else
assert_valid_as_attribute how
[how, what]
end
end
@@ -293,11 +296,14 @@
end
end.join(" and ")
end
def equal_pair(key, value)
- # we assume :label means a corresponding label element, not the attribute
- if key == :label && should_use_label_element?
+ if key == :class
+ klass = XpathSupport.escape " #{value} "
+ "contains(concat(' ', @class, ' '), #{klass})"
+ elsif key == :label && should_use_label_element?
+ # we assume :label means a corresponding label element, not the attribute
"@id=//label[normalize-space()=#{XpathSupport.escape value}]/@for"
else
"#{lhs_for(key)}=#{XpathSupport.escape value}"
end
end