playwright-controller
Fluent API around Playwright
Controller API | Selector API | Assertion API | FAQ | with jest
Installation
npm i --save playwright-controller
This will also install Playwright along with its dependencies and the browser binaries. Browser binaries are about 50-100MB each, so expect the installation network traffic to be substantial.
Usage
; const pwc = ; await pwc ; hasFocus ; ;
This API provides a Selector Fluent API that enables to find and target a DOM element or a collection of DOM elements that is embedded in complex DOM Hierarchy:
const selector = pwc // will get all dom elements, within the current page, with the attribute role="row" // will filter only those that contain the text 'foobar' // from previous result(s), find all embedded <td> elements ; // take only the second cell await pwc;
This API is still a draft and is in early development, but stay tuned!
Contributing
Check out our contributing guide.
Resources
FAQ
Playwright?
Q: How does playwright-controller relate toPlaywright-controller is just a wrapper around the Playwright API. The purpose of Playwright-controller is to be able to write e2e tests as fast as possible in a way that makes tests readable, reusable and maintainable.
Q: Can I start using Playwright-controller in my existing code base?
Yes you can.
; // just create a new instance with playwright's browser and page instancesconst pwc = browser page; // now you can use the fluent API
Q: Can I use Playwright together with the Playwright-controller?
Yes you can. To use the Playwright API, just use the currentBrowser()
and/or currentPage()
methods exposed by the fluent API:
const browser = 'chromium';const pwc = ;await pwc ...; // now if you want to use the playwright API from this point:const browser = pwc;const page = pwc; // the browser and page objects are standard playwright objects// so now you are ready to go by using the playwright API
Q: What can I do with the currently published npm package playwright-controller?
The documentations:
reflect the current status of the development and are inline with the published package.
Q: Do you have some samples on how to use this library with jest?
Yes, have a look to this starter project.