Skip to content

Playwright click #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 20, 2025
Merged

Playwright click #39

merged 4 commits into from
May 20, 2025

Conversation

sjorsdonkers
Copy link
Contributor

@sjorsdonkers sjorsdonkers commented May 12, 2025

Depends on: lightpanda-io/browser#642
Also depends on getComputedStyle since Playwright now requires that after defaultView was implemented.


await page.locator("a[href='campfire-commerce/']").click();
await page.getByText('Campfire Commerce').click();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locator doesn't work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locator fetches both the image and the text links, then complains that there are 2 that match, and suggest to use getByText.
So locator does work now. It just does not seem to be the right playwright tool to use.
Please correct me if I'm mistaken.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chromium runs into the same error:

locator.click: Error: strict mode violation: locator('a[href=\'campfire-commerce/\']') resolved to 2 elements:
    1) <a href="campfire-commerce/">Campfire Commerce</a> aka getByRole('link', { name: 'Campfire Commerce' })
    2) <a href="campfire-commerce/">…</a> aka getByRole('link').nth(1)
```suggestion
await page.getByText('Campfire Commerce').click();

@sjorsdonkers sjorsdonkers changed the title [WIP] playwright click Playwright click May 14, 2025
@sjorsdonkers sjorsdonkers marked this pull request as ready for review May 14, 2025 16:32
@sjorsdonkers sjorsdonkers marked this pull request as draft May 19, 2025 14:33
@sjorsdonkers sjorsdonkers marked this pull request as ready for review May 19, 2025 15:52
@sjorsdonkers sjorsdonkers merged commit 1702bf7 into main May 20, 2025
@sjorsdonkers sjorsdonkers deleted the playwright_click branch May 20, 2025 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants