Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Basic example for Playwright Test fails with Error: toHaveValue can be only used with Locator objectΒ #356

@petetnt

Description

@petetnt

First of all, thanks for working with Testing Library Playwright support πŸ™

In the README there's this following test:

test('my form', async ({queries: {getByTestId}}) => {() const $email = await getByLabelText('Email') expect($email).toHaveValue('playwright@example.com') })

However, this doesn't seem to work with "@playwright/test": "1.17.1", and "@playwright-testing-library/test": "4.0.1", but instead it fails with Error: toHaveValue can be only used with Locator object.

As mentioned in microsoft/playwright#7835 (comment), these APIs are only ever meant to be used with Locator objects, not ElementHandles.

This is possibly fixed / improved by #330 I guess? Not sure if there's any other workarounds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions