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,29 @@ 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
- def browser_context_args (
52
- browser_context_args : Dict , base_url : str , request : SubRequest
53
- ):
51
+ def browser_context_args (browser_context_args : dict , base_url : str , request : SubRequest ) -> dict :
54
52
"""This fixture allows setting browser context arguments for Playwright.
55
53
56
54
Args:
57
55
browser_context_args (dict): Base browser context arguments.
58
56
request (SubRequest): Pytest request object to get the 'browser_context_args' fixture value.
59
57
base_url (str): The base URL for the application under test.
58
+
60
59
Returns:
61
60
dict: Updated browser context arguments.
61
+
62
62
See Also:
63
63
https://playwright.dev/python/docs/api/class-browser#browser-new-contex
64
64
65
65
Returns:
66
66
dict: Updated browser context arguments.
67
+
67
68
"""
68
69
context_args = {
69
70
** browser_context_args ,
@@ -85,7 +86,7 @@ def browser_context_args(
85
86
86
87
87
88
@pytest .fixture (scope = "session" )
88
- def browser_type_launch_args (browser_type_launch_args : Dict , playwright : Playwright ):
89
+ def browser_type_launch_args (browser_type_launch_args : dict , playwright : Playwright ) -> dict :
89
90
"""Fixture to set browser launch arguments.
90
91
91
92
This fixture updates the browser launch arguments to start the browser maximized
@@ -103,6 +104,7 @@ def browser_type_launch_args(browser_type_launch_args: Dict, playwright: Playwri
103
104
104
105
See Also:
105
106
https://playwright.dev/python/docs/api/class-browsertype#browser-type-launch
107
+
106
108
"""
107
109
playwright .selectors .set_test_id_attribute ("data-test" )
108
110
return {** browser_type_launch_args , "args" : ["--start-maximized" ]}
@@ -113,6 +115,7 @@ def get_public_ip() -> str:
113
115
114
116
Returns:
115
117
str: Public IP address.
118
+
116
119
"""
117
120
return requests .get (
118
121
"http://checkip.amazonaws.com" ,
@@ -129,6 +132,7 @@ def attach_playwright_results(page: Page, request: FixtureRequest):
129
132
Args:
130
133
page (Page): Playwright page object.
131
134
request: Pytest request object.
135
+
132
136
"""
133
137
yield
134
138
if request .node .rep_call .failed :
@@ -158,6 +162,7 @@ def pytest_runtest_makereport(item: Item):
158
162
159
163
Yields:
160
164
Outcome of the test execution.
165
+
161
166
"""
162
167
outcome = yield
163
168
rep = outcome .get_result ()
0 commit comments