File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change 11import { readFile } from 'node:fs/promises' ;
22import type { Finding } from './types.d.js' ;
3+ import { sleep } from './sleep.js' ;
34import AxeBuilder from '@axe-core/playwright'
45import playwright from 'playwright' ;
56
67export async function findForUrl ( url : string , sessionStatePath ?: string ) : Promise < Finding [ ] > {
78 const browser = await playwright . chromium . launch ( { headless : true , executablePath : process . env . CI ? '/usr/bin/google-chrome' : undefined } ) ;
8- let sessionState ;
9- if ( sessionStatePath ) {
10- try {
11- sessionState = JSON . parse ( await readFile ( sessionStatePath , 'utf8' ) ) ;
12- } catch ( error ) {
13- console . error ( `Error reading or parsing session state file at path: ${ sessionStatePath } ` , error ) ;
14- }
15- }
16- const context = await browser . newContext ( { storageState : sessionState } ) ;
9+ const context = await browser . newContext ( { storageState : sessionStatePath } ) ;
1710 const page = await context . newPage ( ) ;
1811 await page . goto ( url ) ;
1912
13+ await sleep ( 5000 ) ;
14+ console . log ( page . url ( ) ) ;
15+
2016 let findings : Finding [ ] = [ ] ;
2117 try {
2218 const rawFindings = await new AxeBuilder ( { page } ) . analyze ( ) ;
You can’t perform that action at this time.
0 commit comments