Skip to content

Commit c7b77f9

Browse files
Merge branch '3-assertions' into 4-page-objects
2 parents 1d034c7 + 909bde9 commit c7b77f9

File tree

4 files changed

+36
-16
lines changed

4 files changed

+36
-16
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
# tau-playwright-workshop
22

3-
This repository contains the example code for the Playwright workshop
3+
This repository contains the instructions and example code for the Playwright workshop
44
for [TAU: The Homecoming](https://applitools.com/tau-homecoming/)
55
on December 1, 2021.
66
The workshop will be done in [Python](python.org).
77

8-
The `workshop` folder contains full instructions for the workshop.
9-
That way, you can still code along to learn Playwright even if you miss the main event!
8+
9+
## Instructions
10+
11+
Please try to attend the workshop *live* on the day of the event.
12+
However, if you cannot make it, never fear!
13+
**You can still take the workshop as a self-guided tutorial.**
14+
Start by reading this README.
15+
Then, follow the guides in the `workshop` folder.
16+
Each part of the workshop has a `workshop` guide with full instructions.
17+
Feel free to open issues against this repository if you have any trouble completing the workshop independently.
1018

1119

1220
## Abstract
@@ -41,7 +49,7 @@ If you are using a different shell or a Windows command line, some commands may
4149

4250
## Agenda
4351

44-
This workshop has five main parts:
52+
This workshop has five main parts, each with three sections:
4553

4654
1. Getting started
4755
1. What is Playwright?
@@ -67,7 +75,7 @@ This workshop has five main parts:
6775

6876
## Example code branches
6977

70-
Each part has a corresponding branch in this repository containing the part's example code and `workshop` instructions.
78+
Each workshop part has a corresponding branch in this repository containing the part's example code and `workshop` instructions.
7179
The branches allow you to check your progress at any point during the workshop.
7280
The branch names are:
7381

workshop/1-getting-started.md

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Part 1: Getting started
22

3-
Part 1 of the workshop explains how to start testing with Playwright and pytest in Python.
3+
Part 1 of the workshop explains how to set up a Python test automation project with pytest and Playwright.
44

55

66
## What is Playwright?
@@ -62,13 +62,10 @@ to manage dependency packages locally:
6262

6363
```bash
6464
$ python3 -m venv venv
65-
$ source venv/bin/activate
6665
```
6766

6867
Creating a new virtual environment for each Python project is a recommended practice.
6968
This command will create a subdirectory named `venv` that holds all virtual environment files, including dependency packages.
70-
After creating a virtual environment, you must "activate" it to use it using the `source` command shown above.
71-
You can tell if a virtual environment is active if its name appears in the bash prompt.
7269

7370
*A note about Python commands:*
7471
Python has two incompatible major versions: 2 and 3.
@@ -77,6 +74,21 @@ For example, macOS comes bundled with Python 2.7.18.
7774
Sometimes, the `python` executable may point to Python 2 instead of 3.
7875
To be precise about versions and executables, we will use the `python3` and `pip3` commands explicitly in this workshop.
7976

77+
After creating a virtual environment, you must "activate" it.
78+
On macOS or Linux, use the following command:
79+
80+
```bash
81+
$ source venv/bin/activate
82+
```
83+
84+
The equivalent command for a Windows command line is:
85+
86+
```
87+
> venv\Scripts\activate.bat
88+
```
89+
90+
You can tell if a virtual environment is active if its name appears in the prompt.
91+
8092
Let's add some Python packages to our new virtual environment:
8193

8294
```bash

workshop/2-first-steps.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ However, the `pytest-playwright` plugin takes care of these things automatically
4646
* The `context` fixture provides a new browser context for a test.
4747
* The `page` fixture provides a new browser page for a test.
4848

49-
All of the Playwright calls with `pytest-playwright` use the synchronous API instead of the async API.
50-
The `browser` fixture has session scope, meaning all tests will share one browser instance.
51-
The `context` and `page` fixtures have function scope, meaning each test gets new ones.
49+
All the Playwright calls with `pytest-playwright` use the synchronous API instead of the async API.
50+
The `browser` fixture has *session* scope, meaning all tests will share one browser instance.
51+
The `context` and `page` fixtures have *function* scope, meaning each test gets new ones.
5252
Typically, a test will only need to call the `page` fixture directly.
5353
These fixtures will also automatically clean up everything after testing is complete.
5454
You do not need to explicitly close the browser.
@@ -66,13 +66,13 @@ To this:
6666
def test_basic_duckduckgo_search(page):
6767
```
6868

69-
70-
## Navigating to a web page
71-
7269
Now the test has access to a fresh page in a new browser context.
7370
If we write multiple tests, each test will get its own page and context,
7471
but they will all share the same browser instance.
7572

73+
74+
## Navigating to a web page
75+
7676
Now that we have a page, let's do something on it!
7777
Our first test step is, "Given the DuckDuckGo home page is displayed".
7878
Let's [navigate](https://playwright.dev/python/docs/navigations) to the DuckDuckGo home page like this:

workshop/3-assertions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ the `input_value` method performs *implicit* waiting for the element to be ready
6767
Check the [Auto-waiting](https://playwright.dev/python/docs/actionability) page
6868
for a full list of actionability checks for each interaction.
6969

70-
Rerun the test using the same pytest command (`python3 -m pytest tests --headed --slowmo 1000).
70+
Rerun the test using the same pytest command (`python3 -m pytest tests --headed --slowmo 1000`).
7171
This time, you should see the result page for a good second or two before the browser window closes.
7272
The test should still pass.
7373

0 commit comments

Comments
 (0)