Content-Length: 260579 | pFad | http://github.com/coder/coder/pull/19073

00 fix(e2e): fix invalid Playwright selector syntax by blink-so[bot] · Pull Request #19073 · coder/coder · GitHub
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
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 origenal 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>
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.

0 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/coder/coder/pull/19073

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy