Playwright
qa_pytest_playwright
__all__ = ['PlaywrightSteps', 'PlaywrightTests', 'PlaywrightUiContext', 'PlaywrightUiElement']
module-attribute
PlaywrightSteps
Bases: UiSteps[PlaywrightSteps[TConfiguration]]
BDD-style step definitions for Playwright-based UI operations.
Attributes:
| Name | Type | Description |
|---|---|---|
_ui_context |
UiContext[UiElement]
|
The Playwright UI context used for browser automation. |
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_steps.py
9 10 11 12 13 14 15 16 17 18 19 20 21 | |
PlaywrightTests
Bases: AbstractTestsBase[PlaywrightTests[TSteps], PlaywrightTests[TConfiguration]]
Base class for Playwright-based UI test cases.
This class manages the lifecycle of a Playwright browser and page for each test method. It is generic over the types of steps and configuration used.
Attributes:
| Name | Type | Description |
|---|---|---|
_playwright |
Playwright
|
The Playwright instance. |
_browser |
Browser
|
The Playwright browser instance (not thread safe). |
_page |
Page
|
The Playwright page instance (not thread safe). |
Type Parameters: TSteps: The type of the steps class, typically derived from PlaywrightSteps. TConfiguration: The type of the configuration class, typically derived from UiConfiguration.
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_tests.py
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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
browser
property
Returns the Playwright browser instance.
Returns:
| Name | Type | Description |
|---|---|---|
Browser |
Browser
|
The Playwright browser instance. |
page
property
Returns the Playwright page instance.
Returns:
| Name | Type | Description |
|---|---|---|
Page |
Page
|
The Playwright page instance. |
ui_context
property
setup_method()
Initializes Playwright browser and page before each test method.
If you need to customize browser options or use a different browser, override this method in your test class.
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_tests.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | |
teardown_method()
Closes the Playwright page, browser, and context after each test method.
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_tests.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
PlaywrightUiContext
Bases: UiContext[PlaywrightUiElement]
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
__init__(page)
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
70 71 | |
execute_script(script, *args)
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
88 89 | |
find_element(by, value)
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
73 74 75 76 77 | |
find_elements(by, value)
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
79 80 81 82 83 | |
get(url)
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
85 86 | |
PlaywrightUiElement
Bases: UiElement
Playwright adapter for UiElement protocol. Wraps a Playwright Locator and implements the backend-agnostic UiElement interface.
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
text
property
Get element text content, returning empty string if None.
__getattr__(name)
Delegate all other attribute access to the wrapped Playwright Locator.
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
49 50 51 | |
__init__(locator)
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
24 25 | |
__repr__()
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
60 61 | |
__setattr__(name, value)
Delegate attribute setting to the wrapped Playwright Locator.
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
53 54 55 56 57 58 | |
__str__()
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
63 64 | |
clear()
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
34 35 | |
click()
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
27 28 | |
execute_script(script, *args)
Execute script on this element using the page's evaluate method.
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
40 41 42 | |
scroll_into_view()
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
37 38 | |
type(text)
Source code in qa-pytest-playwright/src/qa_pytest_playwright/playwright_ui_adapter.py
30 31 32 | |