You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The assertion expect(locator).toHaveText(value) accepts arrays as parameter and will check that the locator matches n elements and check that the nth element has the nth text value.
A similar behavior for other assertions would be very useful. In particular I'm in need of said behavior for the toHaveAttribute assertion. See example below.
// unexpected "b" in DOM, "d" not found, "a" found in wrong position
await expect(page.locator(".theClass")).toHaveAttribute("someAttr", ["c", "d", "a"])
Motivation
I can write a function that does what I described, using a combination of expect.poll() and locator.getAttribute but I think this is a general enough case that deserves support out of the box. Motivation is basically ease of use.
The text was updated successfully, but these errors were encountered:
Oscaruzzo
changed the title
[Feature]: have toHaveAttribute(name, value) behave like toHaveText assert when parameter is an array
[Feature]: have toHaveAttribute(name, value) behave like toHaveText() when parameter is an array
Dec 23, 2024
Oscaruzzo
changed the title
[Feature]: have toHaveAttribute(name, value) behave like toHaveText() when parameter is an array
[Feature]: have toHaveAttribute(name, value) behave like toHaveText(value) when parameter is an array
Dec 23, 2024
🚀 Feature Request
The assertion expect(locator).toHaveText(value) accepts arrays as parameter and will check that the locator matches n elements and check that the nth element has the nth text value.
A similar behavior for other assertions would be very useful. In particular I'm in need of said behavior for the toHaveAttribute assertion. See example below.
Example
Given this document
I'd like this code to succeed
await expect(page.locator(".theClass")).toHaveAttribute("someAttr", ["a", "b", "c"])
and this code to fail
Motivation
I can write a function that does what I described, using a combination of expect.poll() and locator.getAttribute but I think this is a general enough case that deserves support out of the box. Motivation is basically ease of use.
The text was updated successfully, but these errors were encountered: