Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 836
Mugatu Avatar asked Jun 02 '26 20:06

Mugatu


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

like image 115
Infern0 Avatar answered Jun 04 '26 09:06

Infern0