-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathconftest.py
More file actions
38 lines (31 loc) · 1.01 KB
/
conftest.py
File metadata and controls
38 lines (31 loc) · 1.01 KB
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
from pytest import fixture
from playwright.sync_api import sync_playwright
SLO_MO = None
HEADLESS = False
@fixture(scope='module')
def chromium():
"""
Main fixture. Creates Chrome browser and yields it into tests
Shows how to work with docs
"""
with sync_playwright() as p:
chromium = p.chromium.launch(headless=HEADLESS, slow_mo=SLO_MO)
yield chromium
chromium.close()
@fixture(scope='module')
def page(chromium):
# base url provided for context, so goto method can user only endpoint
context = chromium.new_context(permissions=["geolocation"],
geolocation={"latitude": 48.8, "longitude": 2.3},
base_url='http://127.0.0.1:8000')
page = context.new_page()
yield page
page.close()
context.close()
@fixture(scope='module')
def alice(page):
page.goto('')
page.fill('#id_username', 'alice')
page.fill('id=id_password', 'Qamania123')
page.click('text="Login"')
return page