isEnabled() assertion returns incorrect value for disabled <label> element
See original GitHub issueI just discovered what I am pretty sure is a bug.
The markup I am using looks like this:
<label id='blah-label-id' disabled="disabled" data-ng-click="handleClick()">
<input type="radio">blah</label>
The Protractor assertion I am using looks like this:
expect(element(by.id('blah-label-id')).isEnabled()).toBe(false);
However, the above assertion fails.
When I test it to see the result of isEnabled()
, it returns true
, when you’d expect it to return false
.
I have tested this by calling getAttribute('disabled')
on the same element – it returns 'true'
(as a string, not a boolean value).
Note that in the same suite of tests, I am successfully using the isEnabled()
assertion on <input type="range">
, <input type="text">
and <button>
elements.
Issue Analytics
- State:
- Created 10 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Selenium Assertion Examples - Practical Applications In Projects
It returns true if a user is able to enter data in it, else if it is disabled, it returns a false value....
Read more >Checking an element is disabled using Puppeteer
I want to check that the button has attribute disabled , however since the attribute has no value in it, I am not...
Read more >Verifying whether an element present or visible in selenium ...
This method verifies if an element is enabled. If the element is enabled, it returns a true value. If not, it returns a...
Read more >cy.type() failed because it targeted a disabled element
This error should never occur without a valid reason. We have analyzed the tests and made sure that the element is ready for...
Read more >How does Selenium isDisplayed() method work | BrowserStack
isEnabled(). This method verifies if an element is enabled. If the element is enabled, it returns a true value. If not, it returns...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m using Chrome 33.0.1750.117 on OSX 10.9.2.
It’s a bit of a nuisance, because I spent a lot of time thinking that the test had failed.
But I have the workaround of using this:
Certainly this behavior is not convenient, but I think it is a correct implementation of HTML 5 specs.
See,
a
andspan
doesn’t have a disabled attribute.If
getAttribute()
works, it must be because the way angular implements directives.As a personal note, these abstractions brought to us by frameworks like bootstrap may hide such subtleties, but we must be aware of.