-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_example.py
39 lines (24 loc) · 1.01 KB
/
test_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import pytest
from playwright.sync_api import Page, expect
# @pytest.fixture(scope="function", autouse=True)
# def before_each_after_each(page: Page):
# print("before the test runs")
# # Go to the starting url before each test.
# page.goto("https://playwright.dev/")
# yield
# print("after the test runs")
# def test_main_navigation(page: Page):
# # Assertions use the expect API.
# expect(page).to_have_url("https://playwright.dev/")
import re
# from playwright.sync_api import Page, expect
def test_has_title(page: Page):
page.goto("https://playwright.dev/")
# Expect a title "to contain" a substring.
expect(page).to_have_title(re.compile("Playwright"))
def test_get_started_link(page: Page):
page.goto("https://playwright.dev/")
# Click the get started link.
page.get_by_role("link", name="Get started").click()
# Expects page to have a heading with the name of Installation.
expect(page.get_by_role("heading", name="Installation")).to_be_visible()