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

Should click event be triggered by clicking on a disabled button? #8004

Closed
VasRoko opened this issue Sep 4, 2023 · 3 comments
Closed

Should click event be triggered by clicking on a disabled button? #8004

VasRoko opened this issue Sep 4, 2023 · 3 comments
Labels
TYPE: question The issue contains a question that won't be addressed.

Comments

@VasRoko
Copy link

VasRoko commented Sep 4, 2023

File a new question on StackOverflow

https://stackoverflow.com/questions/ask?tags=testcafe

@VasRoko VasRoko added the TYPE: question The issue contains a question that won't be addressed. label Sep 4, 2023
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 4, 2023
@github-actions
Copy link

github-actions bot commented Sep 4, 2023

Thank you for your inquiry. This issue looks like a question that would be best asked on StackOverflow - an amazing platform for users to ask and answer questions. We try to keep the GitHub issues tracker for bugs and feature requests only (see Contributing).

If you think that this issue is a bug, feel free to open a new issue, but please make sure to follow the issue template. Thank you in advance.

@github-actions github-actions bot closed this as completed Sep 4, 2023
@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 4, 2023
@VasRoko
Copy link
Author

VasRoko commented Sep 4, 2023

Noticed this request from 2 years ago: #5240 However, should this be allowed behaviour ?

Case scenario:
I have a button that is disabled because user need to accept "terms & conditions", in the browser I can't click or interact with this button (and according to MDN docs that's how it should be) but in testcafe it bypasses disabled attribute and still clicks on that button? Which makes the whole test of "Should not click on submit button unless user accepted terms" and invalid test.

Obviously the workaround is to assert for disabled attribute but I'm still confused if this is intended behaviour?

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Sep 4, 2023
@AlexKamaev
Copy link
Contributor

TestCafe should emulate browser behavior, so a disabled button should not work. I checked this behavior, and it works as expected in the latest TestCafe version.
Here is an example:

<body>
    <button disabled="disabled">click me</button>
    <script>
        document.querySelector('button').addEventListener('click', () => {
            throw new Error('clicked');
        });
    </script>
</body>
test(`t`, async t => {
    await t.click('button');
});

Please check it on your machine and share your results.
Please also update your TestCafe version if you are not using the latest version.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: question The issue contains a question that won't be addressed.
Projects
None yet
Development

No branches or pull requests

2 participants