how to send command in console, from test Playwright js

Viewed 199

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.

1 Answers

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

Example:

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

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

Related