playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Feature]: Support for more native input state assertions

Open eltaro opened this issue 1 month ago • 0 comments

🚀 Feature Request

Is it possible to add more input control state assertions?

In the kit there's already toBeDisabled() and toBeEditable(), but all others that are defined in the element state are missing. I am talking about :invalid :valid, :required, etc.

There are currently ways to check for states manually, which I have to do right now (using Angular specifically) toHaveClass('ng-invalid'), for example, but it would be nice if could just write toBeInvalid() instead.

Example

In Angular

Instead of this: await expect(openingByAttorneyPage.modalFullNameControl).toHaveClass('ng-invalid');

Have this: await expect(openingByAttorneyPage.modalFullNameControl).toBeInvalid();

In any other framework / UI kit you would search for something that signals that specific field to be invalid, required, etc.

Motivation

Increase readability Less typing Use direct browser API instead of a roundabout way of doing the same thing

eltaro avatar Dec 02 '25 11:12 eltaro