Skip to content

fix(e2e): fix invalid Playwright selector syntax #19073

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

Closed
wants to merge 3 commits into from

Conversation

blink-so[bot]
Copy link
Contributor

@blink-so blink-so bot commented Jul 29, 2025

Problem

The e2e tests were failing with this error:

Error: page.waitForSelector: Unexpected token "=" while parsing selector "[role='alert'], .MuiAlert-root, text=Template updated successfully"

The selector was invalid because it mixed CSS selectors with text selectors using commas, which is not valid Playwright syntax.

Solution

Fixed by using page.locator() with :has-text() pseudo-selectors, which is the proper Playwright syntax for combining CSS selectors with text matching:

// Before (invalid)
await page.waitForSelector("[role='alert'], .MuiAlert-root, text=Template updated successfully", {
  state: "visible",
  timeout: 15000,
});

// After (valid)
await page.locator("[role='alert']:has-text('Template updated successfully'), .MuiAlert-root:has-text('Template updated successfully')").first().waitFor({
  state: "visible",
  timeout: 15000,
});

This change:

  • Uses modern Playwright API (locator() + waitFor() instead of waitForSelector())
  • Properly combines CSS selectors with text matching using :has-text()
  • Maintains the original intent of having a robust selector that can match multiple element types

Testing

The fix resolves the syntax error that was causing e2e test failures.

blink-so bot and others added 3 commits July 29, 2025 11:33
This commit addresses several potential sources of flakiness in the
createWorkspace e2e tests:

1. Enhanced disableDynamicParameters function:
   - Use networkidle instead of domcontentloaded for better page loading
   - Add explicit waits for form and checkbox visibility
   - Use more robust selectors for success messages
   - Add timeout buffers for UI state changes

2. Improved createWorkspace function:
   - Use networkidle for more reliable page loading
   - Add form readiness check before filling parameters
   - Add timeout buffer for form element rendering

3. Enhanced fillParameters function:
   - Add explicit timeout to parameter field selectors

These changes should significantly reduce test flakiness by ensuring
all UI elements are fully loaded and stable before interaction.
The selector '[role=\'alert\'], .MuiAlert-root, text=Template updated successfully'
was invalid because it mixed CSS selectors with text selectors using commas.

Fixed by using page.locator() with :has-text() pseudo-selectors which is the
proper Playwright syntax for combining CSS selectors with text matching.

Co-authored-by: jaaydenh <1858163+jaaydenh@users.noreply.github.com>
Apply Biome formatter to fix indentation and formatting issues.

Co-authored-by: jaaydenh <1858163+jaaydenh@users.noreply.github.com>
@github-actions github-actions bot added the stale This issue is like stale bread. label Aug 6, 2025
@github-actions github-actions bot closed this Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale This issue is like stale bread.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy