简体   繁体   中英

how to send command in console, from test Playwright js

Need to send a command to the console '$gui.dispatch('callBarcodeHandler', '98783083')' from test. For example, in the test I log in and I need to send a command to scan the barcode.

Using page.evaluate function you can execute an arbitrary code inside the Browser context aka console

Example:

const windowHeight = await page.evaluate('window.innerHeight');

More info: https://playwright.dev/docs/evaluating

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM