If I try to use next expectation: expect(page.spnApply_element).to have_" /> If I try to use next expectation: expect(page.spnApply_element).to have_" /> If I try to use next expectation: expect(page.spnApply_element).to have_"/>

Make sure that attribute "disabled" equals to "disabled"

577 views Asked by At

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?

1

There are 1 answers

2
Drenmi On BEST ANSWER

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