Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
// Load axe-core source for injection into pages (works with Electron)
let
=
''
;
try
{
const
=
require
.
resolve
(
'axe-core/axe.min.js'
)
;
=
readFileSync
(
,
'utf-8'
)
;
}
catch
{
// axe-core may not be installed; keep axeSource empty to avoid failing module initialization
=
''
;
}
type
PageFunction<Arg,T>
=
(
:
)
=>
T
|
Promise
<
T
>
;
export
interface
AccessibilityScanOptions
{
/** Specific selector to scan. If not provided, scans the entire page. */
?
:
string
;
/** WCAG tags to include (e.g., 'wcag2a', 'wcag2aa', 'wcag21aa'). Defaults to WCAG 2.1 AA. */
?
:
string
[
]
;
/** Rule IDs to disable for this scan. */
?
:
string
[
]
;
/**
* Patterns to exclude from specific rules. Keys are rule IDs, values are strings to match against element target or HTML.
*
* **IMPORTANT**: Adding exclusions here bypasses accessibility checks. Before adding an exclusion:
* 1. File an issue to track the accessibility problem
* 2. Ensure there's a plan to fix the underlying issue (e.g., hover/focus states that axe can't detect)
* 3. Get approval from @anthropics/accessibility team
*/
?
:
{
[
:
string
]
:
string
[
]
}
;
}
export
class
PlaywrightDriver
{
private
static
=
1
;
private
static
=
1
;
private
static
=
1
;
private
static
readonly
:
{
[
:
string
]
:
string
}
=
{
:
'Meta'
,
:
'Control'
,
:
'Shift'
,
:
'Enter'
,
:
'Escape'
,
:
'ArrowRight'
,
:
'ArrowUp'
,
:
'ArrowDown'
,
:
'ArrowLeft'
,
:
'Home'
,
:
'Escape'
}
;
constructor
(
private
readonly
:
.
|
.
,
private
readonly
:
.
,
private
:
.
,
private
readonly
:
|
undefined
,
private
readonly
:
Promise
<
unknown
>
,
private
readonly
:
,
/**
* Wall-clock time sampled when the first recorded page was created, used to
* express captured timestamps as offsets into the recording.
*
* Playwright rebases each video to its first screencast frame, which arrives
* shortly after page creation, so this is an approximation rather than an
* exact origin. Consumers should treat derived offsets as accurate to a
* fraction of a second and must not rely on frame-exact alignment.
*
* Undefined when the run is not recording.
*/
readonly
?
:
number
)
{
}
get
browserContext
(
)
:
.
{
return
this
.
;
}
private
get
page
(
)
:
.
{
return
this
.
;
}
get
currentPage
(
)
:
.
{
return
this
.
;
}
/**
* Get all open windows/pages.
* For Electron apps, returns all Electron windows.
* For browser contexts, returns all pages.
*/
getAllWindows
(
)
:
.
[
]
{
if
(
'windows'
in
this
.
)
{
return
(
this
.
as
.
)
.
windows
(
)
;
}
return
this
.
.
pages
(
)
;
}
/**
* Switch to a different window by index or URL pattern.
* @paramindexOrUrl - Window index (0-based) or a string to match against the URL.
* When using a string, it first tries to find an exact URL match,
* then falls back to finding the first URL that contains the pattern.
* @returns The switched-to page, or undefined if not found
* @note When switching windows, any existing CDP session will be cleared since it
* remains attached to the previous page and cannot be used with the new page.
*/
switchToWindow
(
:
number
|
string
)
:
.
|
undefined
{
const
=
this
.
getAllWindows
(
)
;
if
(
typeof
===
'number'
)
{
if
(
>=
0
&&
<
.
)
{
this
.
=
[
]
;
// Clear CDP session as it's attached to the previous page
this
.
=
undefined
;
return
this
.
;
}
}
else
{
// First try exact match, then fall back to substring match
let
=
.
find
(
=>
.
url
(
)
===
)
;
if
(
!
)
{
=
.
find
(
=>
.
url
(
)
.
includes
(
)
)
;
}
if
(
)
{
this
.
=
;
// Clear CDP session as it's attached to the previous page
this
.
=
undefined
;
return
this
.
;
}
}
return
undefined
;
}
/**
* Get information about all windows.
*/
getWindowsInfo
(
)
:
{
:
number
;
:
string
;
:
boolean
}
[
]
{
const
=
this
.
getAllWindows
(
)
;
return
.
map
(
(
,
)
=>
(
{
,
:
.
url
(
)
,
:
===
this
.
}
)
)
;
}
async
getCDPTargets
(
)
:
Promise
<
.
.
[
]
>
{
const
=
await
this
.
.
newCDPSession
(
this
.
)
;
try
{
return
(
await
.
send
(
'Target.getTargets'
)
)
.
;
}
finally
{
await
.
detach
(
)
;
}
}
async
evaluateCDPTarget<T>
(
:
string
,
:
string
)
:
Promise
<
T
>
{
const
=
await
this
.
sendCDPTargetCommand
(
,
'Runtime.evaluate'
,
{
,
:
true
,
:
true
}
)
as
.
.
;
if
(
.
)
{
throw
new
Error
(
.
.
?.
??
.
.
)
;
}
return
.
.
as
T
;
}
async
evaluateCDPTargetFrame<T>
(
:
string
,
:
string
,
:
string
)
:
Promise
<
T
>
{
const
{
}
=
await
this
.
sendCDPTargetCommand
(
,
'Page.getFrameTree'
,
{
}
)
as
.
.
;
const
=
findFrame
(
,
)
;
let
=
?.
;
if
(
!
)
{
const
{
}
=
await
this
.
sendCDPTargetCommand
(
,
'DOM.getDocument'
,
{
:
-
1
,
:
true
}
)
as
.
DOM
.
;
=
findDOMFrameId
(
,
)
;
}
if
(
!
)
{
throw
new
Error
(
`Frame not found for URL pattern '${frameUrlPattern}'.`
)
;
}
const
{
}
=
await
this
.
sendCDPTargetCommand
(
,
'Page.createIsolatedWorld'
,
{
,
:
'vscodeAutomation'
,
:
true
}
)
as
.
.
;
const
=
await
this
.
sendCDPTargetCommand
(
,
'Runtime.evaluate'
,
{
,
:
,
:
true
,
:
true
}
)
as
.
.
;
if
(
.
)
{
throw
new
Error
(
.
.
?.
??
.
.
)
;
}
return
.
.
as
T
;
}
private
async
sendCDPTargetCommand
(
:
string
,
:
string
,
:
)
:
Promise
<
unknown
>
{
const
=
await
this
.
.
newCDPSession
(
this
.
)
;
let
:
string
|
undefined
;
const
=
1
;
let
:
(
(
:
{
:
string
;
:
string
}
)
=>
void
)
|
undefined
;
let
:
(
(
:
{
:
string
;
?
:
string
}
)
=>
void
)
|
undefined
;
let
:
.
|
undefined
;
try
{
=
(
await
.
send
(
'Target.attachToTarget'
,
{
,
:
false
}
)
)
.
;
const
=
new
Promise<unknown>
(
(
,
)
=>
{
listener
=
=>
{
if
(
.
!==
)
{
return
;
}
const
=
JSON
.
parse
(
.
)
as
{
?
:
number
;
?
:
unknown
;
?
:
{
:
string
}
}
;
if
(
.
!==
)
{
return
;
}
if
(
.
)
{
reject
(
new
Error
(
.
.
)
)
;
}
else
{
resolve
(
.
)
;
}
}
;
detachedListener
=
=>
{
if
(
.
===
)
{
reject
(
new
Error
(
`CDP target '${targetId}' detached while running '${method}'.`
)
)
;
}
}
;
.
on
(
'Target.receivedMessageFromTarget'
,
)
;
.
on
(
'Target.detachedFromTarget'
,
)
;
=
setTimeout
(
(
)
=>
reject
(
new
Error
(
`Timed out running CDP command '${method}' on target '${targetId}'.`
)
)
,
15_000
)
;
}
)
;
const
=
.
send
(
'Target.sendMessageToTarget'
,
{
,
:
JSON
.
stringify
(
{
:
,
,
}
)
}
)
;
const
[
,
]
=
await
Promise
.
all
(
[
,
]
)
;
return
;
}
finally
{
if
(
)
{
.
off
(
'Target.receivedMessageFromTarget'
,
)
;
}
if
(
)
{
.
off
(
'Target.detachedFromTarget'
,
)
;
}
if
(
)
{
clearTimeout
(
)
;
}
if
(
)
{
await
.
send
(
'Target.detachFromTarget'
,
{
}
)
.
catch
(
(
)
=>
undefined
)
;
}
await
.
detach
(
)
;
}
}
/**
* Wait for an open window/page whose URL contains the provided pattern.
*/
async
waitForPage
(
:
string
,
:
number
=
10_000
)
:
Promise
<
.
>
{
const
=
.
now
(
)
+
;
do
{
const
=
this
.
getAllWindows
(
)
.
find
(
=>
!
.
isClosed
(
)
&&
.
url
(
)
.
includes
(
)
)
;
if
(
)
{
return
;
}
await
wait
(
100
)
;
}
while
(
.
now
(
)
<
)
;
const
=
this
.
getAllWindows
(
)
.
map
(
=>
.
url
(
)
)
;
throw
new
Error
(
`Timed out waiting for page matching '${urlPattern}'. Open pages: ${JSON.stringify(openUrls)}`
)
;
}
/**
* Run an action and wait for a newly opened window/page whose URL contains the provided pattern.
*/
async
waitForNewPage
(
:
string
,
action
:
(
)
=>
Promise
<
unknown
>
,
:
number
=
10_000
)
:
Promise
<
.
>
{
const
=
new
Set
(
this
.
getAllWindows
(
)
)
;
await
action
(
)
;
const
=
.
now
(
)
+
;
do
{
const
=
this
.
getAllWindows
(
)
.
find
(
=>
!
.
has
(
)
&&
!
.
isClosed
(
)
&&
.
url
(
)
.
includes
(
)
)
;
if
(
)
{
return
;
}
await
wait
(
100
)
;
}
while
(
.
now
(
)
<
)
;
const
=
this
.
getAllWindows
(
)
.
map
(
=>
.
url
(
)
)
;
throw
new
Error
(
`Timed out waiting for new page matching '${urlPattern}'. Open pages: ${JSON.stringify(openUrls)}`
)
;
}
/**
* Take a screenshot of the current window.
* @paramfullPage - Whether to capture the full scrollable page
* @returns Screenshot as a Buffer
*/
async
screenshotBuffer
(
:
boolean
=
false
)
:
Promise
<
>
{
return
await
this
.
.
screenshot
(
{
:
'png'
,
}
)
;
}
/**
* Get the accessibility snapshot of the current window.
*/
async
getAccessibilitySnapshot
(
)
:
Promise
<
string
>
{
return
await
this
.
.
ariaSnapshot
(
{
:
'ai'
}
)
;
}
/**
* Click on an element using CSS selector with options.
*/
async
clickSelector
(
:
string
,
?
:
{
?
:
'left'
|
'right'
|
'middle'
;
?
:
number
}
)
:
Promise
<
void
>
{
await
this
.
.
click
(
,
{
:
?.
??
'left'
,
:
?.
??
1
}
)
;
}
/**
* Type text into an element.
* @paramselector - CSS selector for the element
* @paramtext - Text to type
* @paramslowly - Whether to type character by character (triggers key events)
*/
async
typeText
(
:
string
,
:
string
,
:
boolean
=
false
)
:
Promise
<
void
>
{
if
(
)
{
await
this
.
.
type
(
,
,
{
:
50
}
)
;
}
else
{
await
this
.
.
fill
(
,
)
;
}
}
/**
* Evaluate a JavaScript expression in the current window.
*/
async
evaluateExpression<T=unknown>
(
:
string
)
:
Promise
<
T
>
{
return
await
this
.
.
evaluate
(
)
as
T
;
}
/**
* Get information about elements matching a selector.
*/
async
getLocatorInfo
(
:
string
,
?
:
'count'
|
'textContent'
|
'innerHTML'
|
'boundingBox'
|
'isVisible'
)
:
Promise
<
number
|
string
[
]
|
{
:
number
;
:
number
;
:
number
;
:
number
}
|
null
|
boolean
|
{
:
number
;
:
boolean
}
>
{
const
=
this
.
.
locator
(
)
;
switch
(
)
{
case
'count'
:
return
await
.
count
(
)
;
case
'textContent'
:
return
await
.
allTextContents
(
)
;
case
'innerHTML'
:
return
await
.
allInnerTexts
(
)
;
case
'boundingBox'
:
return
await
.
first
(
)
.
boundingBox
(
)
;
case
'isVisible'
:
return
await
.
first
(
)
.
isVisible
(
)
;
default
:
return
{
:
await
.
count
(
)
,
:
await
.
first
(
)
.
isVisible
(
)
.
catch
(
(
)
=>
false
)
}
;
}
}
/**
* Wait for an element to reach a specific state.
*/
async
waitForElement
(
:
string
,
?
:
{
?
:
'attached'
|
'detached'
|
'visible'
|
'hidden'
;
?
:
number
}
)
:
Promise
<
void
>
{
await
this
.
.
waitForSelector
(
,
{
:
?.
??
'visible'
,
:
?.
??
30000
}
)
;
}
/**
* Hover over an element.
*/
async
hoverSelector
(
:
string
)
:
Promise
<
void
>
{
await
this
.
.
hover
(
)
;
}
/**
* Drag from one element to another.
*/
async
dragSelector
(
:
string
,
:
string
)
:
Promise
<
void
>
{
await
this
.
.
dragAndDrop
(
,
)
;
}
/**
* Press a key or key combination.
*/
async
pressKey
(
:
string
)
:
Promise
<
void
>
{
await
this
.
.
.
press
(
)
;
}
/**
* Move mouse to a specific position.
*/
async
mouseMove
(
:
number
,
:
number
)
:
Promise
<
void
>
{
await
this
.
.
.
move
(
,
)
;
}
/**
* Click at a specific position.
*/
async
mouseClick
(
:
number
,
:
number
,
?
:
{
?
:
'left'
|
'right'
|
'middle'
;
?
:
number
}
)
:
Promise
<
void
>
{
await
this
.
.
.
click
(
,
,
{
:
?.
??
'left'
,
:
?.
??
1
}
)
;
}
/**
* Drag from one position to another.
*/
async
mouseDrag
(
:
number
,
:
number
,
:
number
,
:
number
)
:
Promise
<
void
>
{
await
this
.
.
.
move
(
,
)
;
await
this
.
.
.
down
(
)
;
await
this
.
.
.
move
(
,
)
;
await
this
.
.
.
up
(
)
;
}
/**
* Select an option in a dropdown.
*/
async
selectOption
(
:
string
,
:
string
|
string
[
]
)
:
Promise
<
string
[
]
>
{
return
await
this
.
.
selectOption
(
,
)
;
}
/**
* Fill multiple form fields at once.
*/
async
fillForm
(
:
{
:
string
;
:
string
}
[
]
)
:
Promise
<
void
>
{
for
(
const
of
)
{
await
this
.
.
fill
(
.
,
.
)
;
}
}
/**
* Get console messages from the current window.
*/
async
getConsoleMessages
(
)
:
Promise
<
{
:
string
;
:
string
}
[
]
>
{
const
=
await
this
.
.
consoleMessages
(
)
;
return
.
map
(
=>
(
{
:
.
type
(
)
,
:
.
text
(
)
}
)
)
;
}
/**
* Wait for text to appear, disappear, or a specified time to pass.
*/
async
waitForText
(
:
{
?
:
string
;
?
:
string
;
?
:
number
}
)
:
Promise
<
void
>
{
const
{
,
,
=
30000
}
=
;
if
(
)
{
await
this
.
.
getByText
(
)
.
first
(
)
.
waitFor
(
{
:
'visible'
,
}
)
;
}
if
(
)
{
await
this
.
.
getByText
(
)
.
first
(
)
.
waitFor
(
{
:
'hidden'
,
}
)
;
}
}
/**
* Wait for a specified time in milliseconds.
*/
// To ensure we have a screenshot at the end where
// it failed, also trigger one explicitly. Tracing
// does not guarantee to give us a screenshot unless
// some driver action ran before.
if
(
)
{
await
this
.
takeScreenshot
(
)
;
}
}
catch
(
)
{
// Ignore
}
}
async
didFinishLoad
(
)
:
Promise
<
void
>
{
await
this
.
;
}
/**
* Stamps the current document so that {@link waitForWindowReload} can tell the
* document apart from the one that a window reload will bring up.
*/
// getElementXY already incorporates both offsets (relative to the element's
// top-left corner) when both are provided, so don't add them again.
if
(
!==
undefined
&&
!==
undefined
)
{
await
this
.
.
.
click
(
,
)
;
}
else
{
await
this
.
.
.
click
(
+
(
??
0
)
,
+
(
??
0
)
)
;
}
}
/**
* Click an element via Playwright's actionability-checked path, with a fallback
* to a stable-coordinates click if Playwright refuses to interact.
*
* The primary path (`page.click`) is preferred because Playwright re-checks
* `elementFromPoint(x, y)` immediately before dispatching, eliminating the
* TOCTOU window where a sibling element could shift the target between the
* position lookup and the click. The fallback only kicks in when a known
* actionability error occurs — specifically when an overlay element intercepts
* pointer events (the known case is Monaco's `.native-edit-context`, z-index: -10,
* which `elementFromPoint` returns instead of the intended target). Other errors
* (e.g. selector not found, detached element, timeout on a genuinely missing
* element) are rethrown so real failures aren't silently masked.
*/
async
robustClick
(
:
string
,
:
number
=
2000
)
:
Promise
<
void
>
{
try
{
await
this
.
.
click
(
,
{
:
}
)
;
return
;
}
catch
(
)
{
if
(
!
this
.
isPointerInterceptedError
(
)
)
{
throw
;
}
try
{
await
this
.
clickAtStablePosition
(
)
;
}
catch
(
)
{
const
=
instanceof
Error
?
.
:
String
(
)
;
const
=
instanceof
Error
?
.
:
String
(
)
;
throw
new
Error
(
`robustClick fallback failed for '${selector}'. Original page.click error: ${orig}. Fallback error: ${fb}`
)
;
}
}
}
/**
* Returns true when the error is an actionability failure caused by an overlay
* element intercepting pointer events (e.g. Monaco's `.native-edit-context`).
* These are the only errors for which the stable-coordinates fallback is safe.
*/
private
isPointerInterceptedError
(
:
unknown
)
:
boolean
{
const
=
instanceof
Error
?
.
:
String
(
)
;
return
.
includes
(
'intercepts pointer events'
)
;
}
/**
* Fallback for {@link robustClick}: polls the element's click position via
* getElementXY until two consecutive samples (separated by `intervalMs`) return
* identical coordinates, then dispatches a mouse click at those exact stable
* coordinates. Clicking the already-sampled {x,y} eliminates the re-sample
* window, making the race window as small as possible (just the CDP round-trip).
*/
private
async
clickAtStablePosition
(
:
string
,
:
number
=
100
,
:
number
=
5000
)
:
Promise
<
void
>
{
let
:
{
:
number
;
:
number
}
|
undefined
;
const
=
.
now
(
)
;
while
(
true
)
{
const
=
await
this
.
getElementXY
(
)
;
if
(
&&
.
===
.
&&
.
===
.
)
{
await
this
.
.
.
click
(
.
,
.
)
;
return
;
}
=
;
if
(
.
now
(
)
-
>
)
{
throw
new
Error
(
`Element position never stabilized for '${selector}' within ${timeoutMs}ms`
)
;
}
await
wait
(
)
;
}
}
async
setValue
(
:
string
,
:
string
)
{
return
this
.
.
evaluate
(
(
[
,
,
]
)
=>
.
setValue
(
,
)
,
[
await
this
.
getDriverHandle
(
)
,
,
]
as
const
)
;
}
async
getTitle
(
)
{
return
this
.
.
title
(
)
;
}
async
isActiveElement
(
:
string
)
{
return
this
.
.
evaluate
(
(
[
,
]
)
=>
.
isActiveElement
(
)
,
[
await
this
.
getDriverHandle
(
)
,
]
as
const
)
;
}
async
getElements
(
:
string
,
:
boolean
=
false
)
{
return
this
.
.
evaluate
(
(
[
,
,
]
)
=>
.
getElements
(
,
)
,
[
await
this
.
getDriverHandle
(
)
,
,
]
as
const
)
;
}
async
getElementXY
(
:
string
,
?
:
number
,
?
:
number
)
{
return
this
.
.
evaluate
(
(
[
,
,
,
]
)
=>
.
getElementXY
(
,
,
)
,
[
await
this
.
getDriverHandle
(
)
,
,
,
]
as
const
)
;
}
async
typeInEditor
(
:
string
,
:
string
)
{
return
this
.
.
evaluate
(
(
[
,
,
]
)
=>
.
typeInEditor
(
,
)
,
[
await
this
.
getDriverHandle
(
)
,
,
]
as
const
)
;
}
async
getEditorSelection
(
:
string
)
{
return
this
.
.
evaluate
(
(
[
,
]
)
=>
.
getEditorSelection
(
)
,
[
await
this
.
getDriverHandle
(
)
,
]
as
const
)
;
}
async
getTerminalBuffer
(
:
string
)
{
return
this
.
.
evaluate
(
(
[
,
]
)
=>
.
getTerminalBuffer
(
)
,
[
await
this
.
getDriverHandle
(
)
,
]
as
const
)
;
}
async
writeInTerminal
(
:
string
,
:
string
)
{
return
this
.
.
evaluate
(
(
[
,
,
]
)
=>
.
writeInTerminal
(
,
)
,
[
await
this
.
getDriverHandle
(
)
,
,
]
as
const
)
;
}
async
getLocaleInfo
(
)
{
return
this
.
evaluateWithDriver
(
(
[
]
)
=>
.
getLocaleInfo
(
)
)
;
}
async
getLocalizedStrings
(
)
{
return
this
.
evaluateWithDriver
(
(
[
]
)
=>
.
getLocalizedStrings
(
)
)
;
}
async
getLogs
(
)
{
return
this
.
.
evaluate
(
(
[
]
)
=>
.
getLogs
(
)
,
[
await
this
.
getDriverHandle
(
)
]
as
const
)
;
}
private
async
evaluateWithDriver<T>
(
:
<
[
]
,
T
>
)
{
return
this
.
.
evaluate
(
,
[
await
this
.
getDriverHandle
(
)
]
)
;
}
wait
(
:
number
)
:
Promise
<
void
>
{
return
wait
(
)
;
}
whenWorkbenchRestored
(
)
:
Promise
<
void
>
{
return
this
.
evaluateWithDriver
(
(
[
]
)
=>
.
whenWorkbenchRestored
(
)
)
;
}
private
async
getDriverHandle
(
)
:
Promise
<
.
<
>>
{
return
this
.
.
evaluateHandle
(
'window.driver'
)
;
}
async
isAlive
(
)
:
Promise
<
boolean
>
{
try
{
await
this
.
getDriverHandle
(
)
;
return
true
;
}
catch
(
)
{
return
false
;
}
}
/**
* Run an accessibility scan on the current page using axe-core.
* Uses direct script injection to work with Electron.
* @paramoptions Configuration options for the accessibility scan.
* @returns The axe-core scan results including any violations found.
*/
async
runAccessibilityScan
(
?
:
)
:
Promise
<
>
{
// Inject axe-core into the page if not already present
await
this
.
.
evaluate
(
)
;
// Build axe-core run options
const
:
=
{
:
{
:
'tag'
,
:
?.
??
[
'wcag2a'
,
'wcag2aa'
,
'wcag21aa'
]
}
}
;
// Disable specific rules if requested
if
(
?.
&&
.
.
>
0
)
{
.
=
{
}
;
for
(
const
of
.
)
{
.
[
]
=
{
:
false
}
;
}
}
// Build context for axe.run
const
:
{
?
:
string
[
]
;
?
:
string
[
]
[
]
}
=
{
}
;
if
(
?.
)
{
.
=
[
.
]
;
}
// Exclude known problematic areas
.
=
[
[
'.monaco-editor .view-lines'
]
,
[
'.xterm-screen canvas'
]
]
;
// Run axe-core analysis
const
=
await
measureAndLog
(
(
)
=>
this
.
.
evaluate
(
(
[
,
]
)
=>
{
// @ts-expect-error axe is injected globally
return
.
.
run
(
,
)
;
}
,
[
,
]
as
const
)
,
'runAccessibilityScan'
,
this
.
.
)
;
return
as
;
}
/**
* Run an accessibility scan and throw an error if any violations are found.
* @paramoptions Configuration options for the accessibility scan.
* @throws Error if accessibility violations are detected.
*/
async
assertNoAccessibilityViolations
(
?
:
)
:
Promise
<
void
>
{
const
=
await
this
.
runAccessibilityScan
(
)
;
// Filter out violations for specific elements based on excludeRules
let
=
.
;
if
(
?.
)
{
=
.
.
map
(
(
:
[
'violations'
]
[
number
]
)
=>
{
const
=
.
!
[
.
]
;
if
(
!
)
{
return
;
}
// Filter out nodes that match any of the exclude patterns
const
=
.
.
filter
(
(
:
[
'violations'
]
[
number
]
[
'nodes'
]
[
number
]
)
=>
{
const
=
.
.
join
(
' '
)
;
const
=
.
||
''
;
// Check if any exclude pattern appears in target or HTML
return
!
.
some
(
=>
.
includes
(
)
||
.
includes
(
)
)
;
}
)
;
return
{
...
,
:
}
;
}
)
.
filter
(
(
:
[
'violations'
]
[
number
]
)
=>
.
.
>
0
)
;
}
if
(
.
>
0
)
{
const
=
.
map
(
(
:
[
'violations'
]
[
number
]
)
=>
{
const
=
.
.
map
(
(
:
[
'violations'
]
[
number
]
[
'nodes'
]
[
number
]
)
=>
{
const
=
.
.
join
(
' > '
)
;
const
=
.
||
'N/A'
;
// Extract class from HTML for easier identification