Playwrightとpytestを使用しWebアプリのエンド ツー エンドのテストができる「pytest-playwright」

スポンサーリンク

Playwrightとpytestを使用しWebアプリのエンド ツー エンドのテストができるライブラリ「pytest-playwright」のインストールについて解説しています。

「pytest-playwright(https://github.com/microsoft/playwright-pytest)」は、Playwright用のPytestプラグインで、Webアプリのエンド ツー エンドのテストが行えます。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■pytest-playwrightをインストールする

pytest-playwrightをインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install pytest-playwright

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install pytest-playwright

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable
Collecting pytest-playwright
Downloading pytest_playwright-0.3.0-py3-none-any.whl (10 kB)
Requirement already satisfied: playwright>=1.18 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest-playwright) (1.27.1)
Requirement already satisfied: python-slugify in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest-playwright) (6.1.2)
Collecting pytest-base-url
Downloading pytest_base_url-2.0.0-py3-none-any.whl (4.6 kB)
Collecting pytest
Downloading pytest-7.2.0-py3-none-any.whl (316 kB)
---------------------------------------- 316.8/316.8 kB 1.5 MB/s eta 0:00:00
Requirement already satisfied: typing-extensions in c:\users\user_\appdata\roaming\python\python38\site-packages (from playwright>=1.18->pytest-playwright) (4.4.0)
Requirement already satisfied: greenlet==1.1.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from playwright>=1.18->pytest-playwright) (1.1.3)
Requirement already satisfied: pyee==8.1.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from playwright>=1.18->pytest-playwright) (8.1.0)
Collecting attrs>=19.2.0
Using cached attrs-22.1.0-py2.py3-none-any.whl (58 kB)
Collecting pluggy<2.0,>=0.12
Using cached pluggy-1.0.0-py2.py3-none-any.whl (13 kB)
Collecting tomli>=1.0.0
Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting exceptiongroup>=1.0.0rc8
Downloading exceptiongroup-1.0.0-py3-none-any.whl (12 kB)
Requirement already satisfied: colorama in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest->pytest-playwright) (0.4.5)
Collecting packaging
Using cached packaging-21.3-py3-none-any.whl (40 kB)
Collecting iniconfig
Using cached iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Requirement already satisfied: requests>=2.9 in c:\users\user_\appdata\roaming\python\python38\site-packages (from pytest-base-url->pytest-playwright) (2.28.1)
Requirement already satisfied: text-unidecode>=1.3 in c:\users\user_\appdata\roaming\python\python38\site-packages (from python-slugify->pytest-playwright) (1.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.9->pytest-base-url->pytest-playwright) (1.26.12)
Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.9->pytest-base-url->pytest-playwright) (2.1.1)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.9->pytest-base-url->pytest-playwright) (2022.9.24)
Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.9->pytest-base-url->pytest-playwright) (3.4)
Collecting pyparsing!=3.0.5,>=2.0.2
Using cached pyparsing-3.0.9-py3-none-any.whl (98 kB)
Installing collected packages: iniconfig, tomli, pyparsing, pluggy, exceptiongroup, attrs, packaging, pytest, pytest-base-url, pytest-playwright
Successfully installed attrs-22.1.0 exceptiongroup-1.0.0 iniconfig-1.1.1 packaging-21.3 pluggy-1.0.0 pyparsing-3.0.9 pytest-7.2.0 pytest-base-url-2.0.0 pytest-playwright-0.3.0 tomli-2.0.1

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、pytest-playwrightが正常にインストールされたことになります。

なお、今回はpytest-playwrightのバージョン0.3.0をインストールしました。

コメント

タイトルとURLをコピーしました