File tree Expand file tree Collapse file tree 3 files changed +28
-16
lines changed
Expand file tree Collapse file tree 3 files changed +28
-16
lines changed Original file line number Diff line number Diff line change 1- const { selectorEngine } = require ( "query-selector-shadow-dom /plugins/playwright" ) ;
1+ const { selectorEngine } = require ( "../.. /plugins/playwright" ) ;
22const playwright = require ( 'playwright' )
33
44const main = async ( ) => {
@@ -10,7 +10,9 @@ const main = async () => {
1010
1111 await page . goto ( 'chrome://downloads' )
1212
13- await page . waitForSelector ( 'shadow=#no-downloads span' , { timeout : 3000 } )
13+ const element = await page . waitForSelector ( './/div' , { timeout : 3000 } )
14+ const span = await element . $$ ( "div > .illustration + span" )
15+ console . log ( span )
1416 await new Promise ( resolve => setTimeout ( resolve , 3000 ) )
1517
1618 await page . close ( )
Original file line number Diff line number Diff line change 11const puppeteer = require ( 'puppeteer' ) ;
2- const path = require ( 'path' ) ;
3- const fs = require ( 'fs' ) ;
2+ const { queryHandler } = require ( "../../plugins/puppeteer" ) ;
43( async ( ) => {
54 try {
5+ puppeteer . __experimental_registerCustomQueryHandler ( 'shadow' , queryHandler ) ;
66 const browser = await puppeteer . launch ( {
7- headless : false
7+ headless : false ,
8+ devtools : true
89 } )
910 const page = await browser . newPage ( )
10- await page . goto ( 'http://127.0.0.1:5500/test/' )
11-
12- // makes the library available in evaluate functions which run within the browser context
13- await page . addScriptTag ( {
14- path : path . join ( __dirname , 'node_modules/query-selector-shadow-dom/dist/querySelectorShadowDom.js' )
15- } ) ;
11+ await page . goto ( 'http://127.0.0.1:5501/test/' )
1612
1713
1814 // ensure btn exists and return it
19- const btn = ( await page . waitForFunction ( ( ) => {
20- const btn = querySelectorShadowDom . querySelectorDeep ( ".btn-in-shadow-dom" ) ;
21- return btn ;
22- } ) ) . asElement ( ) ;
15+ const btn = await page . $ ( "shadow/.btn-in-shadow-dom" ) ;
16+ console . log ( btn ) ;
2317 await btn . click ( ) ;
2418 // check btn was clicked (this page expected btn to change text of output)
25- const outputSpan = await page . evaluateHandle ( ( ) => querySelectorShadowDom . querySelectorDeep ( " .output") ) ;
19+ const outputSpan = await page . $ ( "shadow/ .output") ;
2620 const text = await page . evaluate ( ( output ) => output . innerText , outputSpan ) ;
2721 // prints the text from the output
2822 console . log ( text ) ;
You can’t perform that action at this time.
0 commit comments