microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
66.4k stars 3.63k forks source link

[Bug]: Anchor tag shown as button using bootstrap having disabled attribute is asserted as enabled #32170

Closed karanbir closed 2 months ago

karanbir commented 2 months ago

Version

1.44.0

Steps to reproduce

I have an application where anchor tag are shown as button via bootstrap

One of the button is in disabled state and I want to assert it

image

<a href="javascript:void(0)" id="delete-button" disabled="disabled" class="btn btn-default">Delete</a>

When I assert the same via Playwright (.Net), it is shown as enabled, which is not the case

await Expect(page.FrameLocator("iframe").GetByRole(AriaRole.Link, new() { Name = "Delete" })).ToBeDisabledAsync();

Also, as per official documentation, ToBeDisabledAsync works with only native tags such as HTML button, input, select, textarea, option, optgroup https://playwright.dev/dotnet/docs/api/class-locatorassertions#locator-assertions-to-be-disabled

image

Request you to extend the support for anchor tag as well.

Expected behavior

I expect Playwright to return right state for anchor tag as well

Actual behavior

Anchor tag is asserted as enabled while having disabled attribute defined

Additional context

No response

Environment

OS : Windows
Browser : Chromium
pavelfeldman commented 2 months ago

There is no such thing as disabled link in the web. Even if you choose to render it as a disabled button, user can still tab into it and invoke it or use a11y voice over command to trigger it. You should either use <button> or role button along with either generic or aria-disabled attribute. Search for disabled link on the web and you'll get some recommendations:

https://css-tricks.com/how-to-disable-links/ https://www.scottohara.me/blog/2021/05/28/disabled-links.html