You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -441,6 +441,27 @@ test(
441
441
);
442
442
```
443
443
444
+
To pass variables from the test environment into the browser, you can pass them as the 2nd parameter. Note that they must either be JSON-serializable or they can be a [`JSHandle`](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-class-jshandle) or an [`ElementHandle`](https://pptr.dev/#?product=Puppeteer&version=v7.1.0&show=api-class-elementhandle). The arguments can be received in the browser as parameters to a default-exported function:
445
+
446
+
```js
447
+
import { withBrowser } from'test-mule';
448
+
449
+
test(
450
+
'runJS example with argument',
451
+
withBrowser(async ({ utils, screen }) => {
452
+
// element is an ElementHandle (pointer to an element in the browser)
453
+
constelement=awaitscreen.getByText(/button/i);
454
+
// we can pass element into runJS and the default exported function can access it as an Element
0 commit comments