How can I get value of element custom attribute wi

2019-02-12 17:14发布

问题:

I have HTML that looks like this:

<input custom_attribute="so cool" type="text" />

I would like to get value of custom_attribute using Watir.

回答1:

browser.text_field(:index, 1).attribute_value("custom_attribute")
#=> "so cool"

Sources:

  • http://www.mail-archive.com/wtr-general%40rubyforge.org/msg06769.html
  • http://rdoc.info/gems/watir/1.6.6/Watir/Element#attribute_value-instance_method
  • https://github.com/watir/watir-classic/blob/master/lib/watir-classic/element.rb
  • http://zeljkofilipin.com/watir-select-element-using-custom-attribute/