question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

isEnabled() assertion returns incorrect value for disabled <label> element

See original GitHub issue

I 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:closed
  • Created 10 years ago
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
mcalthropcommented, Mar 5, 2014

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:

expect(element(by.id('blah-label-id')).getAttribute('disabled')).toBe('true')
2reactions
awerlangcommented, Nov 14, 2014

Certainly this behavior is not convenient, but I think it is a correct implementation of HTML 5 specs.

See, a and span 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found