1
- from typing import Dict
2
-
3
1
import allure
4
2
import pytest
5
3
import requests
@@ -27,6 +25,7 @@ def goto(page: Page, request: SubRequest):
27
25
28
26
Example:
29
27
@pytest.mark.parametrize('browser_context_args', ["standard_user"], indirect=True)
28
+
30
29
"""
31
30
if request .getfixturevalue ("browser_context_args" ).get ("storage_state" ):
32
31
page .goto ("/inventory.html" )
@@ -43,27 +42,31 @@ def axe_playwright():
43
42
44
43
Returns:
45
44
AxeHelper: An instance of AxeHelper with Axe initialized.
45
+
46
46
"""
47
- yield AxeHelper (Axe ())
47
+ return AxeHelper (Axe ())
48
48
49
49
50
50
@pytest .fixture (scope = "function" )
51
51
def browser_context_args (
52
- browser_context_args : Dict , base_url : str , request : SubRequest
52
+ browser_context_args : dict , base_url : str , request : SubRequest
53
53
):
54
54
"""This fixture allows setting browser context arguments for Playwright.
55
55
56
56
Args:
57
57
browser_context_args (dict): Base browser context arguments.
58
58
request (SubRequest): Pytest request object to get the 'browser_context_args' fixture value.
59
59
base_url (str): The base URL for the application under test.
60
+
60
61
Returns:
61
62
dict: Updated browser context arguments.
63
+
62
64
See Also:
63
65
https://playwright.dev/python/docs/api/class-browser#browser-new-contex
64
66
65
67
Returns:
66
68
dict: Updated browser context arguments.
69
+
67
70
"""
68
71
context_args = {
69
72
** browser_context_args ,
@@ -85,7 +88,7 @@ def browser_context_args(
85
88
86
89
87
90
@pytest .fixture (scope = "session" )
88
- def browser_type_launch_args (browser_type_launch_args : Dict , playwright : Playwright ):
91
+ def browser_type_launch_args (browser_type_launch_args : dict , playwright : Playwright ):
89
92
"""Fixture to set browser launch arguments.
90
93
91
94
This fixture updates the browser launch arguments to start the browser maximized
@@ -103,6 +106,7 @@ def browser_type_launch_args(browser_type_launch_args: Dict, playwright: Playwri
103
106
104
107
See Also:
105
108
https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch
109
+
106
110
"""
107
111
playwright .selectors .set_test_id_attribute ("data-test" )
108
112
return {** browser_type_launch_args , "args" : ["--start-maximized" ]}
@@ -113,6 +117,7 @@ def get_public_ip() -> str:
113
117
114
118
Returns:
115
119
str: Public IP address.
120
+
116
121
"""
117
122
return requests .get (
118
123
"http://checkip.amazonaws.com" ,
@@ -129,6 +134,7 @@ def attach_playwright_results(page: Page, request: FixtureRequest):
129
134
Args:
130
135
page (Page): Playwright page object.
131
136
request: Pytest request object.
137
+
132
138
"""
133
139
yield
134
140
if request .node .rep_call .failed :
@@ -158,6 +164,7 @@ def pytest_runtest_makereport(item: Item):
158
164
159
165
Yields:
160
166
Outcome of the test execution.
167
+
161
168
"""
162
169
outcome = yield
163
170
rep = outcome .get_result ()
0 commit comments