thefrontside / interactors

Composable page objects for components
https://frontside.com/interactors
MIT License
28 stars 3 forks source link

Do interactors work with Playwright? #191

Open paambaati opened 2 years ago

paambaati commented 2 years ago

As far as I could tell, there’s no documented support for Playwright.

Can this library made to be work with Playwright? Especially when the DOM is available only lazily?

cowboyd commented 2 years ago

Hi @paambaati! Thanks for your question.

The short answer is that there is no current integration between interactors and playwright. However there is no reason that one couldn't be written. The key thing is that the actual interactor code must be running in the browser. That means they must be bundled and loaded by playwright. If you are using the Playwright Test framework, then there is some extra work required because the actual test runner is running in NodeJS, while the page context is running in the browser.

You would need to add the interactors via some mechanism such as an init script https://playwright.dev/docs/api/class-page#page-add-init-script and then invoke them with a JSHandle https://playwright.dev/docs/api/class-jshandle

Eventually we could bundle this into a @interactors/with-playwright-test package so that you could just import them directly and skip this manual setup.

Page | Playwright
* extends: [EventEmitter]
JSHandle | Playwright
JSHandle represents an in-page JavaScript object. JSHandles can be created with the page.evaluateHandle(pageFunction[, arg]) method.