Module 1 · Exercises

How to Run
Exercises

Set up your files and run them with Node.js — no browser needed

Node.js tsx 5 Minutes Beginner
AI with Rufat
1
Step One

Open Project
in VS Code

Open the Playwright project you set up in Module 0 in VS Code. The folder should look like this:

💡 Use File → Open Folder... and select the playwright-course folder.
playwright-course — Visual Studio Code
🔍
Explorer
📁 playwright-course
📄 playwright.config.ts
📁 tests/
📁 node_modules/
📁
Select a file
AI with Rufat
2
Step Two

Create Folder
and Files

Right-click in the Explorer → New Folder → create exercises/mod1. Then add a file for each exercise:

exercise-1.ts   exercise-2.ts   exercise-3.ts
exercise-4.ts   exercise-5.ts   exercise-6.ts
playwright-course — Visual Studio Code
Explorer
📁playwright-course
📁exercises ← new
📁mod1 ← new
📄 exercise-1.ts
📄exercise-2.ts
📄exercise-3.ts
📄exercise-4.ts
📄exercise-5.ts
📄exercise-6.ts
📄playwright.config.ts
AI with Rufat
3
Step Three

Open
the Terminal

In VS Code, go to View → Terminal in the top menu. The terminal panel will open at the bottom of the window.

Or use the keyboard shortcut:
Ctrl + ` ← key below Escape
Once the terminal opens, check that the prompt shows playwright-course — look at the text on the left side of the terminal line.
File
Edit
Selection
View
Command Palette…Ctrl+Shift+P
ExplorerCtrl+Shift+E
TerminalCtrl+`
// exercise-1.ts
var baseURL = 'http://localhost:3000';
TERMINAL PROBLEMS OUTPUT
PS C:\playwright-course>
↑ "playwright-course" visible — you're in the right place!
AI with Rufat
4
Step Four

Run the
Command

Type the command below in the terminal and press Enter:

npx tsx exercises/mod1/exercise-1.ts
💡 For each exercise, just change the number at the end: exercise-2.ts, exercise-3.ts, etc.
PowerShell
PS C:\playwright-course> npx tsx exercises/mod1/exercise-1.ts
Hello!
Exercise 1 done
PS C:\playwright-course>
AI with Rufat
!
tsx not found

tsx
Not Found

If npx tsx gives a "command not found" error — install it once:

npm install -D tsx
💡 After installing, run again: npx tsx exercises/mod1/exercise-1.ts
PowerShell
PS C:\playwright-course> npx tsx exercises/mod1/exercise-1.ts
npm error could not find tsx
PS C:\playwright-course> npm install -D tsx
added 1 package in 3s
PS C:\playwright-course> npx tsx exercises/mod1/exercise-1.ts
Hello!
Exercise 1 done
AI with Rufat
← / → · space