Skip to content

Commit 8e8d713

Browse files
committedMay 30, 2024
[Fixed] Mark Page.Accessibility.snapshot/2 as @deprecated
According to Playwright.dev, accessibility testing should be executed with separate, spacialized libraries. The Playwright implementation is deprecated. This change also removes a failing test, in keeping with the matching removal from Playwright proper. It appears that the browser behavior was considered to be too inconsistent.
1 parent d648eff commit 8e8d713

File tree

2 files changed

+4
-42
lines changed

2 files changed

+4
-42
lines changed
 

‎lib/playwright/page/accessibility.ex

+4-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ defmodule Playwright.Page.Accessibility do
116116
|> (&(Enum.find(&1.children, fn e -> e.readonly end))).()
117117
%{name: "pick me", readonly: true, role: "textbox"}
118118
"""
119-
@spec snapshot(Page.t(), options) :: snapshot
119+
@deprecated "This method is deprecated. Please use other libraries such as
120+
[Axe](https://www.deque.com/axe/) if you need to test page accessibility.
121+
See the Playwright.dev Node.js [guide](https://playwright.dev/docs/accessibility-testing)
122+
for integration with Axe."
120123
def snapshot(page, options \\ %{})
121124

122125
def snapshot(%Page{session: session} = page, options) do

‎test/integration/page/accessibility_test.exs

-41
Original file line numberDiff line numberDiff line change
@@ -120,47 +120,6 @@ defmodule Playwright.Page.AccessibilityTest do
120120
}
121121
end
122122

123-
test "retains rich text editable fields", %{page: page} do
124-
Page.set_content(page, """
125-
<div contenteditable="true">
126-
Edit this image:<img src="fakeimage.png" alt="my fake image">
127-
</div>
128-
""")
129-
130-
[element | _] = Page.Accessibility.snapshot(page).children
131-
132-
assert element == %{
133-
role: "generic",
134-
name: "",
135-
value: "Edit this image:",
136-
children: [
137-
%{role: "text", name: "Edit this image:"},
138-
%{role: "image", name: "my fake image"}
139-
]
140-
}
141-
end
142-
143-
test "retains rich text editable fields with role", %{page: page} do
144-
Page.set_content(page, """
145-
<div contenteditable="true" role="textbox">
146-
Edit this image:<img src="fakeimage.png" alt="my fake image">
147-
</div>
148-
""")
149-
150-
[element | _] = Page.Accessibility.snapshot(page).children
151-
152-
assert element == %{
153-
role: "textbox",
154-
name: "",
155-
multiline: true,
156-
value: "Edit this image:",
157-
children: [
158-
%{role: "text", name: "Edit this image:"},
159-
%{role: "image", name: "my fake image"}
160-
]
161-
}
162-
end
163-
164123
test "excludes children from plain text editable fields with role", %{page: page} do
165124
Page.set_content(page, """
166125
<div contenteditable="plaintext-only" role="textbox">Edit this image:<img src="fakeimage.png" alt="my fake image"></div>

0 commit comments

Comments
 (0)
Failed to load comments.