-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest_context.py
More file actions
31 lines (24 loc) · 1005 Bytes
/
test_context.py
File metadata and controls
31 lines (24 loc) · 1005 Bytes
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
from pytest import fixture
import random as r
@fixture(scope='module')
def bob(chromium):
context = chromium.new_context(permissions=["geolocation"],
geolocation={"latitude": 10, "longitude": 10})
page = context.new_page()
page.goto('http://127.0.0.1:8000')
page.fill('#id_username', 'bob')
page.fill('id=id_password', 'Qamania123')
page.click('text="Login"')
return page
# read more https://playwright.dev/python/docs/multi-pages
def test_roles(alice, bob):
total = bob.text_content('.total span')
alice.click('a[href="/test/new"]')
alice.fill('#id_name', f'test name {r.random()}')
alice.fill('#id_description', 'new test!')
alice.click('.btn input')
# make sure response received before checking text content
with bob.expect_response(lambda response: response.status == 200):
bob.click('.refresh input')
new_total = bob.text_content('.total span')
assert int(total) + 1 == int(new_total)