0

I have a span with attribute "disabled"

<span disabled="disabled" id="Apply">

If I try to use next expectation:

expect(page.spnApply_element).to have_attributes(:disabled => "disabled")

I get an error:

expected #<Watir::Span:0x..fe4257660 located=false selector={:id=>"Apply", :tag_name=>"span"}> to respond to :disabled with 0 arguments

How to use expectation which validate "disabled" attribute that it equals to disabled?

Den Silver
  • 199
  • 16
  • Isn't this the same as your previously answered question [http://stackoverflow.com/questions/30983017/get-the-actual-value-of-a-boolean-attribute](http://stackoverflow.com/q/30983017/1200545)? If not, can you elaborate on the difference? – Justin Ko Oct 02 '15 at 12:58

1 Answers1

1

The have_attributes method is an RSpec matcher used to test Ruby objects. To test the actual HTML attribute, you should be able to use the Watir method attribute_value like so:

expect(page.spnApply_element.attribute_value("disabled")).to be
Drenmi
  • 8,492
  • 4
  • 42
  • 51
  • 1
    getting next error: `expected: "disabled" got: "true"` – Den Silver Oct 02 '15 at 09:54
  • 1
    Right. In HTML5, `disabled` is an attribute that doesn't take a value (e.g. ``), so this is actually correct. You can match using `be_truthy` or just `be`. – Drenmi Oct 02 '15 at 11:20