Playwright with JavaScript and TypeScript Lecture Notes
Introduction
- Welcome by Naveen from Naveen Automation Lab.
- Starting a new series on Playwright using JavaScript and TypeScript.
- Comparison with Selenium in different programming languages (Python, Java).
Importance of JavaScript Knowledge
- Basic understanding of JavaScript is essential before diving into Playwright.
- Topics to cover:
- For loops
- Conditional statements
- String manipulations
- Arrays and functions
- Object creation
- Common mistakes:
- Jumping into Playwright without proper language knowledge leads to confusion.
Setting Up Playwright on Windows
Prerequisites
- Download Node.js
- Node.js is a server environment required for Playwright.
- Ensure to install the correct version (Windows installer).
- Download Visual Studio Code
- Recommended editor for JavaScript development.
- Link will be provided in video description.
Installation Steps
- Install Node.js
- Double-click the installer and follow the prompts.
- Verify installation by running
node --version
and npm --version
in the command prompt.
- Install Visual Studio Code
- Download and install from the official site.
Setting Up Playwright Project
- Bookmark the official Playwright website for documentation.
- After installing Node.js, create a new folder for the Playwright project in your desired directory.
- Open Visual Studio Code and select the newly created folder.
Installing Playwright
- Open the terminal in Visual Studio Code.
- Run the command to initialize Playwright:
npm init playwright@latest
- Answer prompts regarding TypeScript/JavaScript and testing configurations.
- Confirm downloading of Playwright browsers (Chromium, Firefox, WebKit).
Project Structure
- After installation, check for:
node_modules
: Contains all necessary libraries.
tests
: Directory for test specifications.
package.json
: Contains project dependencies and configurations.
playwright.config.ts
: Configuration file for Playwright settings.
Writing Basic Tests
Running Tests in Headed Mode
- To see the browser actions, run with the
--headed
option:
npx playwright test --headed
Generating Reports
- Use
npx playwright show-report
to view reports after test execution.
- Reports show results for each test case across different browsers.
Additional Commands
- Run tests for specific projects or folders.
- Modify parallel execution settings in
playwright.config.ts
.
- Customize configurations for various browsers and devices directly in the config file.
Conclusion
- Importance of practice and writing tests in Playwright.
- Future sessions will cover advanced topics and real-time examples.
- Encouragement to subscribe and share the content.
Note: This is a summary of the lecture and further details can be explored in follow-up sessions.