Skip to content

Commit 376f98d

Browse files
Merge branch '1-getting-started' into 2-first-steps
2 parents fa21005 + cf2a1f8 commit 376f98d

File tree

9 files changed

+84
-53
lines changed

9 files changed

+84
-53
lines changed

README.md

Lines changed: 62 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,66 @@
1-
![Workshop card](workshop/images/workshop-card.png)
1+
![Playwright banner](tutorial/images/playwright-banner.jpeg)
22

3-
# tau-playwright-workshop
43

5-
This repository contains the instructions and example code for the Playwright workshop
6-
for [TAU: The Homecoming](https://applitools.com/tau-homecoming/)
7-
on December 1, 2021.
8-
The workshop will be done in [Python](https://www.python.org/).
4+
# Tutorial: Web Testing with Playwright in Python
95

106

11-
## Instructions
7+
## Abstract
128

13-
Please try to attend the workshop *live* on the day of the event.
14-
However, if you cannot make it, never fear!
15-
**You can still take the workshop as a self-guided tutorial.**
16-
Start by reading this README.
17-
Then, follow the guides in the `workshop` folder.
18-
Each part of the workshop has a `workshop` guide with full instructions.
19-
Feel free to open issues against this repository if you have any trouble completing the workshop independently.
9+
Everybody gets frustrated when web apps are broken,
10+
but testing them thoroughly doesn't need to be a chore.
11+
[Playwright](https://playwright.dev/python/),
12+
a new open-source browser automation tool from Microsoft,
13+
makes testing web apps fun!
14+
Playwright outperforms other browser automation with a slew of nifty features
15+
like automatic waiting, mobile emulation, and network interception.
16+
Plus, with isolated browser contexts,
17+
Playwright tests can set up *much* faster than traditional Web UI tests.
2018

19+
In this tutorial, we will build a [Python](https://www.python.org/)
20+
test automation project from the ground up using Playwright.
21+
We will automate web search engine tests together step-by-step
22+
using Playwright for interactions and pytest for execution.
23+
We'll also explore Playwright tricks
24+
like cross-browser testing, capturing videos, and even running tests in parallel!
25+
By the end of this tutorial, you'll be empowered to test modern web apps with modern web test tools.
26+
You'll also have an example project to be the foundation for your future tests.
2127

22-
## Abstract
2328

24-
[Playwright](https://playwright.dev/python/)
25-
is a hot new browser automation tool from Microsoft.
26-
With bindings for .NET, Java, JavaScript, and Python, it’s a strong alternative to Selenium WebDriver for end-to-end web app testing.
29+
## What is Playwright?
2730

28-
This workshop will be an introduction to Playwright using [Python](https://www.python.org/).
29-
We will automate a test scenario together that performs a [DuckDuckGo](https://duckduckgo.com/) search.
30-
As we code along the test together, we will learn:
31+
Playwright is a fairly new test automation framework from Microsoft.
32+
It is open source, and it has bindings in TypeScript/JavaScript, Python, .NET, and Java.
33+
Some of the nice features Playwright offers include:
3134

32-
* How to install and configure Playwright
33-
* How to integrate Playwright with [pytest](https://docs.pytest.org/), Python’s leading test framework
34-
* How to perform interactions through page objects
35-
* How to conveniently run different browsers, capture videos, and run tests in parallel
35+
* concise, readable calls
36+
* easy out-of-the-box setup
37+
* very fast execution times (compared to other browser automation tools)
38+
* cross-browser and mobile emulation support
39+
* automatic waiting
40+
* built-in API calls
41+
* screenshots and video capture
3642

37-
Come prepared with Python 3.7 or higher installed on your machine.
38-
By the end of the workshop, you will have a solid foundation in Playwright as well as a Python project you can extend with new tests!
43+
Microsoft is actively developing Playwright,
44+
so new features are coming all the time!
3945

4046

41-
## Prerequisites
47+
## Tutorial Instructions
4248

43-
To code along with this workshop, your machine must have Python 3.7 or higher.
44-
You should also have a decent Python editor like
45-
[Visual Studio Code](https://code.visualstudio.com/docs/languages/python)
46-
or [PyCharm](https://www.jetbrains.com/pycharm/).
49+
You can take this tutorial independently by following the instructions
50+
in this `README` and in the [`tutorial`](tutorial) folder.
51+
Feel free to open issues against this repository if you have any trouble completing the tutorial independently.
4752

48-
The command line shown in examples below is [bash](https://en.wikipedia.org/wiki/Bash_(Unix_shell)).
49-
If you are using a different shell or a Windows command line, some commands may need to be different.
53+
I also have given (or will be giving) this tutorial as a live workshop at the following events:
5054

55+
* [TAU: The Homecoming](https://applitools.com/on-demand-videos/tau-the-homecoming-2021/) (December 1, 2021)
56+
* [Python Web Conference 2022](https://2022.pythonwebconf.com/tutorials/end-to-end-testing-with-playwright) (March 22, 2021)
57+
* [STAREast 2022](https://stareast.techwell.com/program/tutorials/web-ui-testing-playwright-python-stareast-2022) (April 26, 2022)
58+
* [PyCon US 2022](https://us.pycon.org/2022/schedule/presentation/35/) (April 28, 2022)
5159

52-
## Agenda
5360

54-
This workshop has five main parts, each with three sections:
61+
## Outline
62+
63+
This tutorial has five main parts, each with three sections:
5564

5665
1. Getting started
5766
1. What is Playwright?
@@ -75,10 +84,25 @@ This workshop has five main parts, each with three sections:
7584
3. Running tests in parallel
7685

7786

87+
## Prerequisites
88+
89+
You must have basic Python programming skills to complete this tutorial.
90+
If you are new to Python, check out the free
91+
[Python Programming](https://testautomationu.applitools.com/python-tutorial/) course
92+
on Test Automation University.
93+
94+
Your machine must also have Python 3.7 or higher installed.
95+
You can download the latest version of Python from [Python.org](https://www.python.org/).
96+
97+
You should also have a decent Python editor like
98+
[Visual Studio Code](https://code.visualstudio.com/docs/languages/python)
99+
or [PyCharm](https://www.jetbrains.com/pycharm/).
100+
101+
78102
## Example code branches
79103

80-
Each workshop part has a corresponding branch in this repository containing the part's example code and `workshop` instructions.
81-
The branches allow you to check your progress at any point during the workshop.
104+
Each tutorial part has a corresponding branch in this repository containing the part's example code and `tutorial` instructions.
105+
The branches allow you to check your progress at any point during the tutorial.
82106
The branch names are:
83107

84108
| Part | Branch |

requirements.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ greenlet==1.1.2
55
idna==3.3
66
iniconfig==1.1.1
77
packaging==21.3
8-
playwright==1.17.0
8+
playwright==1.19.1
99
pluggy==1.0.0
1010
py==1.11.0
11-
pyee==8.2.2
11+
pyee==8.1.0
1212
pyparsing==3.0.6
13-
pytest==6.2.5
13+
pytest==7.0.1
1414
pytest-base-url==1.4.2
15-
pytest-playwright==0.2.2
15+
pytest-playwright==0.2.3
1616
python-slugify==5.0.2
1717
requests==2.26.0
1818
text-unidecode==1.3
1919
toml==0.10.2
20+
tomli==2.0.1
2021
urllib3==1.26.7
2122
websockets==10.1

workshop/1-getting-started.md renamed to tutorial/1-getting-started.md

Lines changed: 17 additions & 11 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 set up a Python test automation project with pytest and Playwright.
3+
Part 1 of the tutorial explains how to set up a Python test automation project with pytest and Playwright.
44

55

66
## What is Playwright?
@@ -24,7 +24,7 @@ from the docs.
2424

2525
## Our web search test
2626

27-
For this workshop, we will walk through one test scenario for DuckDuckGo searching.
27+
For this tutorial, we will walk through one test scenario for DuckDuckGo searching.
2828
[DuckDuckGo](https://duckduckgo.com/) is a search engine like Google or Yahoo.
2929

3030
The steps for a basic DuckDuckGo search are:
@@ -46,14 +46,14 @@ It is also important to try a test manually before attempting to automate it.
4646
## Test project setup
4747

4848
Let's set up the test project!
49-
For this workshop, we will build a new project from the ground up.
49+
For this tutorial, we will build a new project from the ground up.
5050
The GitHub repository should be used exclusively as a reference for example code.
5151

52-
Create a directory named `tau-playwright-workshop` for the project:
52+
Create a directory named `playwright-python-tutorial` for the project:
5353

5454
```bash
55-
$ mkdir tau-playwright-workshop
56-
$ cd tau-playwright-workshop
55+
$ mkdir playwright-python-tutorial
56+
$ cd playwright-python-tutorial
5757
```
5858

5959
Inside this project, create a [Python virtual environment](https://docs.python.org/3/tutorial/venv.html)
@@ -72,7 +72,7 @@ Python has two incompatible major versions: 2 and 3.
7272
Although Python 2 end-of-life was January 1, 2020, many machines still run it.
7373
For example, macOS comes bundled with Python 2.7.18.
7474
Sometimes, the `python` executable may point to Python 2 instead of 3.
75-
To be precise about versions and executables, we will use the `python3` and `pip3` commands explicitly in this workshop.
75+
To be precise about versions and executables, we will use the `python3` and `pip3` commands explicitly in this tutorial.
7676

7777
After creating a virtual environment, you must "activate" it.
7878
On macOS or Linux, use the following command:
@@ -97,6 +97,11 @@ $ pip3 install pytest
9797
$ pip3 install pytest-playwright
9898
```
9999

100+
> If you want to run the tests from this repository instead of creating a fresh project,
101+
> install the dependencies using this command:
102+
>
103+
> `$ pip3 install -r requirements.txt`
104+
100105
By itself, Playwright is simply a library for browser automation.
101106
We need a test framework like pytest if we want to automate tests.
102107
The [`pytest-playwright`](https://playwright.dev/python/docs/test-runners)
@@ -114,18 +119,19 @@ greenlet==1.1.2
114119
idna==3.3
115120
iniconfig==1.1.1
116121
packaging==21.3
117-
playwright==1.17.0
122+
playwright==1.19.1
118123
pluggy==1.0.0
119124
py==1.11.0
120-
pyee==8.2.2
125+
pyee==8.1.0
121126
pyparsing==3.0.6
122-
pytest==6.2.5
127+
pytest==7.0.1
123128
pytest-base-url==1.4.2
124-
pytest-playwright==0.2.2
129+
pytest-playwright==0.2.3
125130
python-slugify==5.0.2
126131
requests==2.26.0
127132
text-unidecode==1.3
128133
toml==0.10.2
134+
tomli==2.0.1
129135
urllib3==1.26.7
130136
websockets==10.1
131137
```
File renamed without changes.
76.5 KB
Loading

workshop/images/workshop-card.png

-292 KB
Binary file not shown.

0 commit comments

Comments
 (0)