Skip to content

[Feature]: Optional value in LocatorAssertions to_have_attribute and not_to_have_attribute #3133

Description

@sarahboyce

🚀 Feature Request

Node.js can assert .toHaveAttribute(name) and not.toHaveAttribute(name). See: https://playwright.dev/docs/api/class-locatorassertions#locator-assertions-to-have-attribute-2

It would be useful for Python to have the same where value in to_have_attribute/not_to_have_attribute is optional: https://playwright.dev/python/docs/api/class-locatorassertions#locator-assertions-to-have-attribute

Example

No response

Motivation

This aligns to functionality in Node.js and reduces regex used in Python plawright. This usecase is common
For example see: https://stackoverflow.com/questions/77681420/python-playwright-how-can-i-check-that-an-element-does-not-have-an-href

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions