Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
docs(skill): add eval examples for inspecting element attributes (#39728)
Yury Semikhatsky66f55cbbf872
diff --git a/packages/playwright-core/src/skill/SKILL.md b/packages/playwright-core/src/skill/SKILL.mdindex 4865d3337e..2206087769 100644--- a/packages/playwright-core/src/skill/SKILL.md+++ b/packages/playwright-core/src/skill/SKILL.md@@ -46,6 +46,9 @@ playwright-cli snapshotplaywright-cli snapshot --filename=after-click.yamlplaywright-cli eval "document.title"playwright-cli eval "el => el.textContent" e5+# get element id, class, or any attribute not visible in the snapshot+playwright-cli eval "el => el.id" e5+playwright-cli eval "el => el.getAttribute('data-testid')" e5playwright-cli dialog-acceptplaywright-cli dialog-accept "confirmation text"playwright-cli dialog-dismiss@@ -307,3 +310,4 @@ playwright-cli close* **Test generation** [references/test-generation.md](references/test-generation.md)* **Tracing** [references/tracing.md](references/tracing.md)* **Video recording** [references/video-recording.md](references/video-recording.md)+* **Inspecting element attributes** [references/element-attributes.md](references/element-attributes.md)diff --git a/packages/playwright-core/src/skill/references/element-attributes.md b/packages/playwright-core/src/skill/references/element-attributes.mdnew file mode 100644index 0000000000..4e9fa6b991--- /dev/null+++ b/packages/playwright-core/src/skill/references/element-attributes.md@@ -0,0 +1,23 @@+# Inspecting Element Attributes++When the snapshot doesn't show an element's `id`, `class`, `data-*` attributes, or other DOM properties, use `eval` to inspect them.++## Examples++```bash+playwright-cli snapshot+# snapshot shows a button as e7 but doesn't reveal its id or data attributes++# get the element's id+playwright-cli eval "el => el.id" e7++# get all CSS classes+playwright-cli eval "el => el.className" e7++# get a specific attribute+playwright-cli eval "el => el.getAttribute('data-testid')" e7+playwright-cli eval "el => el.getAttribute('aria-label')" e7++# get a computed style property+playwright-cli eval "el => getComputedStyle(el).display" e7+```