Code Generation
When tests are developed along the code, is easy to know what items are going to be used on tests, and can be coded in parallel. For already developed applications, searching for item attributes and positions is a lenghty process.
The Playwright CLI
Playwright includes a command line interface to help generating code as a web site or application is being used. To use it, write on the command prompt
> playwright-cli codegen [-b navigator] [url]
Where navigator is one of these:
- ff for firefox
- wk for webkit
- cr for chromium
url is the URL for the initial page
When you run this command, a new browser page appears, and all interactions are being logged on the console. Also, when you hover on an element, a selector appears as a guide.
When a session is finished, close the browser and use the log as a reference to create your tests.
The test
Try to use the Playwright CLI help to solve the Button and Dropdown menus on the Selenium Playground.