-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: add focused and focusable information to _snapshotForAI #36059
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
base: main
Are you sure you want to change the base?
Changes from 2 commits
31d1797
c9453ed
7783506
6473964
4a40ed7
e9746cc
d14a0c1
5056a57
44bc50b
1b45524
74d6d98
002a235
a7f952f
cfb46a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -231,3 +231,27 @@ it('should gracefully fallback when child frame cant be captured', async ({ page | |
- iframe [ref=e3] | ||
`); | ||
}); | ||
|
||
it('should include focused and focusable information', async ({ page }) => { | ||
await page.setContent(` | ||
<button id="btn1">Button 1</button> | ||
<button id="btn2" autofocus>Button 2</button> | ||
<div>Not focusable</div> | ||
`); | ||
|
||
const snapshot = await snapshotForAI(page); | ||
|
||
// Check for Button 1 with focusable attribute | ||
expect(snapshot).toContain('button "Button 1"'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot Instead of checking individual lines, can you have one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the test to use a single There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I don't see any There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've updated the tests to use |
||
expect(snapshot).toContain('[focusable]'); | ||
|
||
// Check for Button 2 with focusable attribute | ||
expect(snapshot).toContain('button "Button 2"'); | ||
expect(snapshot).toMatch(/Button 2.*\[focusable\]/); | ||
|
||
// Check that there's a focused element somewhere in the snapshot | ||
expect(snapshot).toContain('[focused]'); | ||
|
||
// Check for the non-focusable div | ||
expect(snapshot).toContain('Not focusable'); | ||
}); |
Uh oh!
There was an error while loading. Please reload this page.