Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky failed on action type() due to disabled element #28172

Open
kduy969 opened this issue Oct 28, 2023 · 10 comments
Open

Flaky failed on action type() due to disabled element #28172

kduy969 opened this issue Oct 28, 2023 · 10 comments
Labels
stage: awaiting response Potential fix was proposed; awaiting response stale no activity on this issue for a long period

Comments

@kduy969
Copy link

kduy969 commented Oct 28, 2023

Current behavior

My command: cy.get(...).find(...).type('something')

Most of the time the type action will be successful but sometimes I get this error due to disabled element:
image

There is a note said: "Ensure the element does not have an attribute named disabled before typing into it." but the input element showed in the screenshot ( reported by Cypress ) did not contains any attribute name 'disabled'.

Desired behavior

The target element does not contain the "disabled" attribute, type action should not fail.

Test code to reproduce

cy.get(...).find(...).type('something')

Cypress Version

13.3.2

Node version

16.15.0

Operating System

macOS 14.0 (23A344)

Debug Logs

No response

Other

No response

@jennifer-shehane
Copy link
Member

@kduy969 Is the element disabled at any time? It could be a timing issue - where this attribute exists, fails the test, but then immediately removed the attribute and that element without the attribute is used in the error message? If it has a disabled attr, you could add a check before to ensure it doesn't before attempting to type to give it more stability.

@jennifer-shehane jennifer-shehane added the stage: awaiting response Potential fix was proposed; awaiting response label Nov 2, 2023
@yang
Copy link

yang commented Nov 3, 2023

@jennifer-shehane Our code looks like this:

      cy.get('inputselector:not([disabled])')
        .should("not.be.disabled")
        .clear()
        .type(text);

And it fails maybe 30% of the time. We can trigger it by running this in a loop.

This happened immediately after we upgraded from cypress 13.2.0 to the newly released 13.4.0.

@kduy969
Copy link
Author

kduy969 commented Nov 6, 2023

you could add a check before to ensure it doesn't before attempting to type to give it more stability

I can but I thought that kind of check was already made by Cypress when I used the "type" command.
Refer to this doc: https://docs.cypress.io/guides/core-concepts/interacting-with-elements , at section "Checks and Actions Performed"

@kduy969
Copy link
Author

kduy969 commented Nov 6, 2023

where this attribute exists, fails the test, but then immediately removed the attribute and that element without the attribute is used in the error message

Thanks, I will take a look but I think the log message should be accurate since dev rely on that to detect bug.

@provokateurin
Copy link

Same problem here, but for me it fails almost all the time (more like 90%)

@Regenhardt
Copy link

Refer to #5830 and #5827, both were closed after someone posted the workaround .type('something', { force: true }), which does work for using the element, but also invalidates the test as it will still type something if the element is actually disabled.

@alexeyhimself
Copy link

Guys, I just faced this issue on Cypress 13.7.0.

Investigated the problem and found, that the input fields are actually disabled on page load for a few milliseconds and then they get enabled by the app -- that's why it becomes unclear why does this "failed because it targeted disabled element" error appears for enabled element. And that's why it feels "fluky" for ones and stable for another. But looks like it's not a "fluky" bug in Cypress. It's in an app itself!

Try:

cy.wait(1000)

before

cy.get('input').type('hello');

and you'll probably will not see the problem anymore because the app will enable disabled elements during wait period.

Please, let me know if it worked for you and let's close this bug if it's really the app's behavior. Thanks!

@TestIsTest001
Copy link

I am checking that the input is not disabled before:
cy.get('input').should('not.be.disabled') - pass
cy.get('input').type() - fail

And the test is failing at the type part saying the element is disabled

@DaveEvans-Thalamos
Copy link

I hit this due to a SSR hydration race condition. I found this strategy to wait for client hydration via a useEffect worked well for me.
robipop22/dnb-stack#3 (comment)

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label Dec 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: awaiting response Potential fix was proposed; awaiting response stale no activity on this issue for a long period
Projects
None yet
Development

No branches or pull requests

9 participants