Repository navigation
Description
Background
Several Playwright page-object locators in e2e/rstudio/pages/source_pane.page.ts need to target an element that exists inside every open source-editor tab (publishBtn, formatOptions, knitOptions, saveBtn, visualMdToggle, contentPane, aceTextInput, nesGutter, footerTable, previewBtn, ...). With more than one tab open -- which is now the steady state since tests start from a single Untitled placeholder rather than an empty source pane -- a plain page-wide locator strict-matches multiple elements and the assertion fails.
The workaround in tree today is a hand-rolled XPath that scopes to the visible tabpanel by sniffing inline style="display: none":
this.publishBtn = page.locator(
"xpath=//div[@role='tabpanel' and not(contains(@style, 'display: none'))]" +
"//*[starts-with(@id,'rstudio_publish_item_editor')]"
);Six locators already share this prefix, and any new per-tab element added to a toolbar will need the same treatment.
Why this is brittle
- Tied to GWT
TabLayoutPanel's internal inline-style behavior. If that ever switches fromdisplay: nonetovisibility: hidden, hidden custom attribute, etc., every test-side locator silently starts matching the wrong thing. - Hard to read at a glance and easy to copy wrong (the
not(contains(@style, 'display: none'))clause is exact-string sensitive -- e.g.display:nonewithout the space wouldn't match). - Pushes test authors toward XPath when CSS would be more idiomatic for everything else in the page object.
Suggested DOM-side changes (pick one)
Option A -- mark the inactive tab content. Set aria-hidden="true" on the inactive [role='tabpanel'] containers inside the source pane (and clear it on the active one). Test locators collapse to:
this.publishBtn = page.locator(
"[role='tabpanel']:not([aria-hidden='true']) [id^='rstudio_publish_item_editor']"
);This is a one-line CSS selector and aria-hidden is also semantically correct for assistive tech.
Option B -- give the active source-tab content a stable id. Wrap the visible tabpanel with something like id="rstudio_active_source_panel" (updated when the active tab changes). Locators become:
this.publishBtn = page.locator(
"#rstudio_active_source_panel [id^='rstudio_publish_item_editor']"
);Either change would let us delete the XPath wrappers and stop chasing the same scope bug every time we add a new per-tab button to a toolbar.
Scope
- Find where
WorkbenchTabPanel/SourceColumnswap the active source tab and toggle the marker there. - Update the six existing scoped locators in
e2e/rstudio/pages/source_pane.page.tsto the simpler CSS form. - No behavior change for end users; this is purely a test-infrastructure ergonomics improvement.
Context
Surfaced while working on Playwright flake removal -- see the test-infra refactor PR for the current XPath-based fix.
Activity
harden playwright tests against shared-state and locator-scope flakes
fix import dataset preview by removing embedding dependency from .rs.…
github-actions commentedon Nov 26, 2026
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, per https://github.com/rstudio/rstudio/wiki/Issue-Grooming. Thank you for your contributions.