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.

Allow {force: true} option to disable error checking on select & select options

See original GitHub issue

Allow {force: true} to be passed to cy.select (just as type & check commands), that disables error checking so that you can “select” a disabled select or option.

Example Code

index.html

<html>
<body>
  <select id="disabled-select" disabled>
    <option value="456">apples</option>
    <option value="457">oranges</option>
    <option value="458">bananas</option>
  </select>

  <select id="disabled-option">
    <option value="456">apples</option>
    <option value="457" disabled>oranges</option>
    <option value="458">bananas</option>
  </select>
</body>
</html>

spec.js

it('test disabled select', () => {
  cy.visit('index.html')
  cy.get('#disabled-select').select('oranges')
})

it('test disabled option', () => {
  cy.visit('index.html')
  cy.get('#disabled-option').select('oranges')
})
Screen Shot 2020-04-27 at 10 13 05 AM

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:6
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
davidmunechikacommented, Sep 29, 2021

We have decided not to implement this {force: true} option because there is no way to retrieve the value from selected disabled options (due to the nature of jQuery’s .val). Therefore, this would prevent verifying the actual values of the selected options and cause common assertions such as cy.select('foo', {force: true}).invoke('val').should('eq', 'foo') to fail.

1reaction
spaghetticodecommented, Aug 13, 2019

would love to see this happen ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make {force:true} in click() function the default behavior
I am keep getting this visibility error (This element ''is not visible because its parent...) when trying to click links/buttons using the click( ......
Read more >
fix this problem, or use {force: true} to disable error checking.
Since your element is covered by another element, you can use click({force: true}) , to disable the error checking and perform the click....
Read more >
Allow {force: true} option to disable error checking on select & select ...
Allow {force: true} to be passed to cy.select (just as type & check commands), that disables error checking so that you can "select"...
Read more >
select - Cypress Documentation
Passing { force: true } to .select() will override the actionability checks for selecting a disabled <select> . However, it will not override...
Read more >
Usage Documentation - Tom Select
Or more exactly, the list of the values of the selected options. ... Setting closeAfterSelect to true will force the dropdown to close...
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