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.

Cypress should not allow selecting a disabled option within a disabled fieldset

See original GitHub issue

Current behavior:

If you disable a form group it is still possible to change the value of a select input inside

Desired behavior:

the select input is disabled so should error telling you it is unchangeable, similar to the not visible error

Steps to reproduce: (app code and test code)

<fieldset _ngcontent-c15="" class="nopadding" disabled="">
  <div _ngcontent-c15="" class="form-group">
      <label _ngcontent-c15="" for="selectBox">Test Select</label>
      <select _ngcontent-c15="" class="form-control ng-valid ng-untouched ng-pristine" formcontrolname="selectBox" id="selectBox" ng-reflect-name="selectBox">
          <option _ngcontent-c15="" disabled="true" value="0: undefined" hidden="">
              Select Version
          </option>
          <option _ngcontent-c15="" value="1" ng-reflect-value="1">1</option>
          <option _ngcontent-c15="" value="2" ng-reflect-value="2">2</option>
          <option _ngcontent-c15="" value="3" ng-reflect-value="3">3</option>
          <option _ngcontent-c15="" value="4" ng-reflect-value="4">4</option>
          <option _ngcontent-c15="" value="5" ng-reflect-value="5">5</option>
          <option _ngcontent-c15="" value="6" ng-reflect-value="6">6</option>
          <option _ngcontent-c15="" value="7" ng-reflect-value="7">7</option>
          <option _ngcontent-c15="" value="8" ng-reflect-value="8">8</option>
          <option _ngcontent-c15="" value="9" ng-reflect-value="9">9</option>
          <option _ngcontent-c15="" value="10" ng-reflect-value="10">10</option>
      </select>
  </div>
</fieldset>
cy.get('select')
  .filter('#selectBox')
  .select(3)
  .find(':selected')
  .should('contain', 0)

Versions

cy: 3.5 os: windows 10 browser: chrome 78

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jennifer-shehanecommented, Oct 20, 2020

I can recreate this. This likely has to do with us not considering a fieldset that is disabled - that it will disable all selects within it.

it('selects', () => { 
  cy.visit('index.html') 
  cy.get('select').find(':selected').should('contain', 1) 
  cy.get('select').select('3').find(':selected').should('contain', 1) 
})
<html>
<body>
  <fieldset disabled="">
    <select>
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
    </select>
  </fieldset>
</body>
</html>
Screen Shot 2020-10-20 at 4 12 33 PM
0reactions
jennifer-shehanecommented, Apr 28, 2021

Released in 7.2.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to Cypress v7.2.0, please open a new issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to check disabled item in a <select> - cypress
Im trying to write a test that should check if an item in a is disabled. The item is visible, but not clickable,...
Read more >
<fieldset>: The Field Set element - HTML - MDN Web Docs
Disabled fieldset ​​ This example shows a disabled <fieldset> with two controls inside it. Note how both the controls are disabled due to...
Read more >
fix this problem, or use {force: true} to disable error checking.
We have decided not to implement this {force: true} option because there is no way to retrieve the value from selected disabled options...
Read more >
How to Check if Your Buttons Are Disabled or Not In Cypress
To check if your buttons are disabled in Cypress or not, you can use the should('be.disabled') or should('not.be.enabled') assertions.
Read more >
Cross Browser Compatibility of disabled attribute of the ...
Note: On Mozilla Firefox 95,disabled attribute of the fieldset element is Fully Supported. Let's say that if you plan to use this feature,...
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