Skip to main content

A plugin to run pyppeteer in pytest.

Project description

pytest-pyppeteer

A plugin to run pyppeteer in pytest.

PyPI - Python Version GitHub issues PyPI PyPI - Downloads Code style: black Documentation Status

Installation

You can install pytest-pyppeteer via pip:

$ pip install pytest-pyppeteer

or install the latest one on Github:

pip install git+https://github.com/luizyao/pytest-pyppeteer.git

Quickstart

For example, query the rating of the movie The Shawshank Redemption on douban.com.

from dataclasses import dataclass


@dataclass(init=False)
class Elements:
    url = "https://movie.douban.com/"

    query = "#inp-query"
    apply = ".inp-btn > input:nth-child(1)"

    result = (
        "#root > div > div > div > div > div:nth-child(1) > div.item-root a.cover-link"
    )
    rating = (
        "#interest_sectl > div.rating_wrap.clearbox > div.rating_self.clearfix > strong"
    )


async def test_pyppeteer(pyppeteer):
    page = await pyppeteer.new_page()
    await page.goto(Elements.url)

    await page.type(Elements.query, "The Shawshank Redemption")
    await page.click(Elements.apply)

    await page.waitfor(Elements.result)
    await page.click(Elements.result)

    await page.waitfor(Elements.rating)
    rating = await page.get_value(Elements.rating)
    assert rating == 0

License

Distributed under the terms of the MIT license, pytest-pyppeteer is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pytest-pyppeteer-0.2.3.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytest_pyppeteer-0.2.3-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file pytest-pyppeteer-0.2.3.tar.gz.

File metadata

  • Download URL: pytest-pyppeteer-0.2.3.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for pytest-pyppeteer-0.2.3.tar.gz
Algorithm Hash digest
SHA256 343557800c1a6b9da63c99c95aa442d2825ea6cde7ee138a975f0534baaf33ed
MD5 3f21498579ca41507a703590c5cf4ace
BLAKE2b-256 afa06709af36a7decdfff45af5959d23a7effc4fdbe550443a70748b844f497f

See more details on using hashes here.

File details

Details for the file pytest_pyppeteer-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pytest_pyppeteer-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 13.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for pytest_pyppeteer-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b9dc76dcf98e1e728aa1744fd9fd6113286e5d1255252481133ad3f26509dd38
MD5 075dcc56b361a99017640b8176d2d0c6
BLAKE2b-256 bee10cd3e400b0aba7412bb4a1c2a07c4592587e761571df93a0257727da3e4f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page