Skip to content

WebDriver

qa_pytest_webdriver

__all__ = ['By', 'Locator', 'SearchContext', 'SeleniumConfiguration', 'SeleniumSteps', 'SeleniumTests'] module-attribute

By

Factory for Selenium locators, matching Selenium's By API.

Provides static methods to create Locator objects for each Selenium locator strategy.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
 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
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
class By:
    """
    Factory for Selenium locators, matching Selenium's By API.

    Provides static methods to create Locator objects for each Selenium locator strategy.
    """

    @staticmethod
    def id(value: str) -> Locator:
        """
        Creates a locator for elements with the given id attribute.

        Args:
            value (str): The id value.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.ID, value)

    @staticmethod
    def xpath(value: str) -> Locator:
        """
        Creates a locator for elements matching the given XPath expression.

        Args:
            value (str): The XPath expression.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.XPATH, value)

    @staticmethod
    def link_text(value: str) -> Locator:
        """
        Creates a locator for elements with the given link text.

        Args:
            value (str): The link text.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.LINK_TEXT, value)

    @staticmethod
    def partial_link_text(value: str) -> Locator:
        """
        Creates a locator for elements with the given partial link text.

        Args:
            value (str): The partial link text.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.PARTIAL_LINK_TEXT, value)

    @staticmethod
    def name(value: str) -> Locator:
        """
        Creates a locator for elements with the given name attribute.

        Args:
            value (str): The name value.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.NAME, value)

    @staticmethod
    def tag_name(value: str) -> Locator:
        """
        Creates a locator for elements with the given tag name.

        Args:
            value (str): The tag name.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.TAG_NAME, value)

    @staticmethod
    def class_name(value: str) -> Locator:
        """
        Creates a locator for elements with the given class name.

        Args:
            value (str): The class name.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.CLASS_NAME, value)

    @staticmethod
    def css_selector(value: str) -> Locator:
        """
        Creates a locator for elements matching the given CSS selector.

        Args:
            value (str): The CSS selector.
        Returns:
            Locator: The locator object.
        """
        return Locator(_By.CSS_SELECTOR, value)

class_name(value) staticmethod

Creates a locator for elements with the given class name.

Parameters:

Name Type Description Default
value str

The class name.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
142
143
144
145
146
147
148
149
150
151
152
@staticmethod
def class_name(value: str) -> Locator:
    """
    Creates a locator for elements with the given class name.

    Args:
        value (str): The class name.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.CLASS_NAME, value)

css_selector(value) staticmethod

Creates a locator for elements matching the given CSS selector.

Parameters:

Name Type Description Default
value str

The CSS selector.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
154
155
156
157
158
159
160
161
162
163
164
@staticmethod
def css_selector(value: str) -> Locator:
    """
    Creates a locator for elements matching the given CSS selector.

    Args:
        value (str): The CSS selector.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.CSS_SELECTOR, value)

id(value) staticmethod

Creates a locator for elements with the given id attribute.

Parameters:

Name Type Description Default
value str

The id value.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
70
71
72
73
74
75
76
77
78
79
80
@staticmethod
def id(value: str) -> Locator:
    """
    Creates a locator for elements with the given id attribute.

    Args:
        value (str): The id value.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.ID, value)

Creates a locator for elements with the given link text.

Parameters:

Name Type Description Default
value str

The link text.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
 94
 95
 96
 97
 98
 99
100
101
102
103
104
@staticmethod
def link_text(value: str) -> Locator:
    """
    Creates a locator for elements with the given link text.

    Args:
        value (str): The link text.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.LINK_TEXT, value)

name(value) staticmethod

Creates a locator for elements with the given name attribute.

Parameters:

Name Type Description Default
value str

The name value.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
118
119
120
121
122
123
124
125
126
127
128
@staticmethod
def name(value: str) -> Locator:
    """
    Creates a locator for elements with the given name attribute.

    Args:
        value (str): The name value.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.NAME, value)

Creates a locator for elements with the given partial link text.

Parameters:

Name Type Description Default
value str

The partial link text.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
106
107
108
109
110
111
112
113
114
115
116
@staticmethod
def partial_link_text(value: str) -> Locator:
    """
    Creates a locator for elements with the given partial link text.

    Args:
        value (str): The partial link text.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.PARTIAL_LINK_TEXT, value)

tag_name(value) staticmethod

Creates a locator for elements with the given tag name.

Parameters:

Name Type Description Default
value str

The tag name.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
130
131
132
133
134
135
136
137
138
139
140
@staticmethod
def tag_name(value: str) -> Locator:
    """
    Creates a locator for elements with the given tag name.

    Args:
        value (str): The tag name.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.TAG_NAME, value)

xpath(value) staticmethod

Creates a locator for elements matching the given XPath expression.

Parameters:

Name Type Description Default
value str

The XPath expression.

required

Returns: Locator: The locator object.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
82
83
84
85
86
87
88
89
90
91
92
@staticmethod
def xpath(value: str) -> Locator:
    """
    Creates a locator for elements matching the given XPath expression.

    Args:
        value (str): The XPath expression.
    Returns:
        Locator: The locator object.
    """
    return Locator(_By.XPATH, value)

Locator dataclass

Represents a Selenium locator as a (by, value) pair.

Attributes:

Name Type Description
by str

The Selenium locator strategy (e.g., By.ID, By.XPATH).

value str

The locator value.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
@dataclass(frozen=True)
class Locator:
    """
    Represents a Selenium locator as a (by, value) pair.

    Attributes:
        by (str): The Selenium locator strategy (e.g., By.ID, By.XPATH).
        value (str): The locator value.
    """
    by: str
    value: str

    def as_tuple(self) -> Tuple[str, str]:
        """
        Returns the locator as a tuple (by, value), suitable for Selenium APIs.

        Returns:
            Tuple[str, str]: The locator as a tuple.
        """
        return (self.by, self.value)

by instance-attribute

value instance-attribute

__init__(by, value)

as_tuple()

Returns the locator as a tuple (by, value), suitable for Selenium APIs.

Returns:

Type Description
Tuple[str, str]

Tuple[str, str]: The locator as a tuple.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
53
54
55
56
57
58
59
60
def as_tuple(self) -> Tuple[str, str]:
    """
    Returns the locator as a tuple (by, value), suitable for Selenium APIs.

    Returns:
        Tuple[str, str]: The locator as a tuple.
    """
    return (self.by, self.value)

SearchContext

Bases: Protocol

Protocol for Selenium search contexts (e.g., WebDriver, WebElement).

Provides methods to find single or multiple elements using Selenium's locator strategy.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
28
29
30
31
32
33
34
35
36
37
38
class SearchContext(Protocol):
    """
    Protocol for Selenium search contexts (e.g., WebDriver, WebElement).

    Provides methods to find single or multiple elements using Selenium's locator strategy.
    """

    def find_element(self, by: str, value: Optional[str]) -> WebElement: ...

    def find_elements(
        self, by: str, value: Optional[str]) -> List[WebElement]: ...

find_element(by, value)

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
35
def find_element(self, by: str, value: Optional[str]) -> WebElement: ...

find_elements(by, value)

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
37
38
def find_elements(
    self, by: str, value: Optional[str]) -> List[WebElement]: ...

SeleniumConfiguration

Bases: BaseConfiguration

SeleniumConfiguration extends BaseConfiguration to provide Selenium-specific configuration options.

This class exposes properties for retrieving the UI URL and initializing the Selenium WebDriver Service, leveraging configuration values and dynamic driver management.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_configuration.py
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class SeleniumConfiguration(BaseConfiguration):
    """
    SeleniumConfiguration extends BaseConfiguration to provide Selenium-specific configuration options.

    This class exposes properties for retrieving the UI URL and initializing the Selenium WebDriver Service,
    leveraging configuration values and dynamic driver management.
    """

    @cached_property
    @final
    def landing_page(self) -> str:
        """
        Returns the UI URL from the configuration parser.

        Returns:
            str: The URL string specified under the "selenium/base" in the configuration.

        Raises:
            KeyError: If the "selenium" section or "base" key is not present in the configuration parser.
        """
        return self.parser["selenium"]["landing_page"]

    # FIXME Service here is imported from selenium.webdriver.chrome.service
    # which makes this method specific to ChromeDriver.
    @cached_property
    @final
    def service(self) -> Service:
        """
        Creates and returns a Selenium WebDriver Service instance using the ChromeDriverManager.

        Returns:
            Service: An instance of Selenium's Service class, initialized with the path to the ChromeDriver executable
            installed by ChromeDriverManager.

        Note:
            This method currently supports only ChromeDriver, but may be extended to support different services
            based on configuration in the future.
        """
        # NOTE may add support for providing different services per configuration
        return Service(ChromeDriverManager().install())

landing_page cached property

Returns the UI URL from the configuration parser.

Returns:

Name Type Description
str str

The URL string specified under the "selenium/base" in the configuration.

Raises:

Type Description
KeyError

If the "selenium" section or "base" key is not present in the configuration parser.

service cached property

Creates and returns a Selenium WebDriver Service instance using the ChromeDriverManager.

Returns:

Name Type Description
Service Service

An instance of Selenium's Service class, initialized with the path to the ChromeDriver executable

Service

installed by ChromeDriverManager.

Note

This method currently supports only ChromeDriver, but may be extended to support different services based on configuration in the future.

SeleniumSteps

Bases: GenericSteps[TConfiguration]

BDD-style step definitions for Selenium-based UI operations.

Type Parameters

TConfiguration: The configuration type, must be a SeleniumConfiguration.

Attributes:

Name Type Description
_web_driver WebDriver

The Selenium WebDriver instance used for browser automation.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
class SeleniumSteps[TConfiguration: SeleniumConfiguration](
    GenericSteps[TConfiguration]
):
    """
    BDD-style step definitions for Selenium-based UI operations.

    Type Parameters:
        TConfiguration: The configuration type, must be a SeleniumConfiguration.

    Attributes:
        _web_driver (WebDriver): The Selenium WebDriver instance used for browser automation.
    """
    _web_driver: WebDriver

    @final
    @Context.traced
    def clicking_once(self, element_supplier: ElementSupplier) -> Self:
        """
        Clicks the element supplied by the given callable.

        Args:
            element_supplier (ElementSupplier): Callable returning a WebElement.
        Returns:
            Self: The current step instance for chaining.
        """
        element_supplier().click()
        return self

    @overload
    def clicking(self, element: Locator) -> Self: ...

    @overload
    def clicking(self, element: ElementSupplier) -> Self: ...

    @final
    def clicking(self, element: LocatorOrSupplier) -> Self:
        """
        Clicks the element specified by a locator or supplier, with retry logic.

        Args:
            element (LocatorOrSupplier): Locator or callable returning a WebElement.
        Returns:
            Self: The current step instance for chaining.
        """
        return self.retrying(lambda: self.clicking_once(self._resolve(element)))

    @final
    @Context.traced
    def typing_once(self, element_supplier: ElementSupplier, text: str) -> Self:
        """
        Types the given text into the element supplied by the callable.

        Args:
            element_supplier (ElementSupplier): Callable returning a WebElement.
            text (str): The text to type.
        Returns:
            Self: The current step instance for chaining.
        """
        element = element_supplier()
        element.clear()
        element.send_keys(text)
        return self

    @overload
    def typing(self, element: Locator, text: str) -> Self: ...

    @overload
    def typing(self, element: ElementSupplier, text: str) -> Self: ...

    @final
    def typing(self, element: LocatorOrSupplier, text: str) -> Self:
        """
        Types the given text into the element specified by a locator or supplier, with retry logic.

        Args:
            element (LocatorOrSupplier): Locator or callable returning a WebElement.
            text (str): The text to type.
        Returns:
            Self: The current step instance for chaining.
        """
        return self.retrying(lambda: self.typing_once(self._resolve(element), text))

    @final
    def the_element(self, locator: Locator, by_rule: Matcher[WebElement], context: Optional[SearchContext] = None) -> Self:
        """
        Asserts that the element found by the locator matches the given matcher.

        Args:
            locator (Locator): The locator to find the element.
            by_rule (Matcher[WebElement]): Matcher for the element.
            context (Optional[SearchContext]): Optional search context.
        Returns:
            Self: The current step instance for chaining.
        """
        return self.eventually_assert_that(lambda: self._element(locator, context), by_rule)

    @final
    def the_elements(self, locator: Locator, by_rule: Matcher[Iterator[WebElement]], context: Optional[SearchContext] = None) -> Self:
        """
        Asserts that the elements found by the locator match the given matcher.

        Args:
            locator (Locator): The locator to find the elements.
            by_rule (Matcher[Iterator[WebElement]]): Matcher for the elements iterator.
            context (Optional[SearchContext]): Optional search context.
        Returns:
            Self: The current step instance for chaining.
        """
        return self.eventually_assert_that(lambda: self._elements(locator, context), by_rule)

    @final
    @Context.traced
    def _elements(
        self, locator: Locator, context: Optional[SearchContext] = None
    ) -> Iterator[WebElement]:
        return iter((context or self._web_driver).find_elements(*locator.as_tuple()))

    @final
    @Context.traced
    def _element(
        self, locator: Locator, context: Optional[SearchContext] = None
    ) -> WebElement:
        return self._scroll_into_view(
            (context or self._web_driver).find_element(*locator.as_tuple())
        )

    def _scroll_into_view(self, element: WebElement) -> WebElement:
        self._web_driver.execute_script(  # type: ignore
            "arguments[0].scrollIntoView({behavior: 'smooth', block: 'center'});", element)
        return element

    @final
    def _resolve(self, element: LocatorOrSupplier) -> ElementSupplier:
        if isinstance(element, Locator):
            return lambda: self._element(element)
        return element

clicking(element)

clicking(element: Locator) -> Self
clicking(element: ElementSupplier) -> Self

Clicks the element specified by a locator or supplier, with retry logic.

Parameters:

Name Type Description Default
element LocatorOrSupplier

Locator or callable returning a WebElement.

required

Returns: Self: The current step instance for chaining.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
205
206
207
208
209
210
211
212
213
214
215
@final
def clicking(self, element: LocatorOrSupplier) -> Self:
    """
    Clicks the element specified by a locator or supplier, with retry logic.

    Args:
        element (LocatorOrSupplier): Locator or callable returning a WebElement.
    Returns:
        Self: The current step instance for chaining.
    """
    return self.retrying(lambda: self.clicking_once(self._resolve(element)))

clicking_once(element_supplier)

Clicks the element supplied by the given callable.

Parameters:

Name Type Description Default
element_supplier ElementSupplier

Callable returning a WebElement.

required

Returns: Self: The current step instance for chaining.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
185
186
187
188
189
190
191
192
193
194
195
196
197
@final
@Context.traced
def clicking_once(self, element_supplier: ElementSupplier) -> Self:
    """
    Clicks the element supplied by the given callable.

    Args:
        element_supplier (ElementSupplier): Callable returning a WebElement.
    Returns:
        Self: The current step instance for chaining.
    """
    element_supplier().click()
    return self

the_element(locator, by_rule, context=None)

Asserts that the element found by the locator matches the given matcher.

Parameters:

Name Type Description Default
locator Locator

The locator to find the element.

required
by_rule Matcher[WebElement]

Matcher for the element.

required
context Optional[SearchContext]

Optional search context.

None

Returns: Self: The current step instance for chaining.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
253
254
255
256
257
258
259
260
261
262
263
264
265
@final
def the_element(self, locator: Locator, by_rule: Matcher[WebElement], context: Optional[SearchContext] = None) -> Self:
    """
    Asserts that the element found by the locator matches the given matcher.

    Args:
        locator (Locator): The locator to find the element.
        by_rule (Matcher[WebElement]): Matcher for the element.
        context (Optional[SearchContext]): Optional search context.
    Returns:
        Self: The current step instance for chaining.
    """
    return self.eventually_assert_that(lambda: self._element(locator, context), by_rule)

the_elements(locator, by_rule, context=None)

Asserts that the elements found by the locator match the given matcher.

Parameters:

Name Type Description Default
locator Locator

The locator to find the elements.

required
by_rule Matcher[Iterator[WebElement]]

Matcher for the elements iterator.

required
context Optional[SearchContext]

Optional search context.

None

Returns: Self: The current step instance for chaining.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
267
268
269
270
271
272
273
274
275
276
277
278
279
@final
def the_elements(self, locator: Locator, by_rule: Matcher[Iterator[WebElement]], context: Optional[SearchContext] = None) -> Self:
    """
    Asserts that the elements found by the locator match the given matcher.

    Args:
        locator (Locator): The locator to find the elements.
        by_rule (Matcher[Iterator[WebElement]]): Matcher for the elements iterator.
        context (Optional[SearchContext]): Optional search context.
    Returns:
        Self: The current step instance for chaining.
    """
    return self.eventually_assert_that(lambda: self._elements(locator, context), by_rule)

typing(element, text)

typing(element: Locator, text: str) -> Self
typing(element: ElementSupplier, text: str) -> Self

Types the given text into the element specified by a locator or supplier, with retry logic.

Parameters:

Name Type Description Default
element LocatorOrSupplier

Locator or callable returning a WebElement.

required
text str

The text to type.

required

Returns: Self: The current step instance for chaining.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
240
241
242
243
244
245
246
247
248
249
250
251
@final
def typing(self, element: LocatorOrSupplier, text: str) -> Self:
    """
    Types the given text into the element specified by a locator or supplier, with retry logic.

    Args:
        element (LocatorOrSupplier): Locator or callable returning a WebElement.
        text (str): The text to type.
    Returns:
        Self: The current step instance for chaining.
    """
    return self.retrying(lambda: self.typing_once(self._resolve(element), text))

typing_once(element_supplier, text)

Types the given text into the element supplied by the callable.

Parameters:

Name Type Description Default
element_supplier ElementSupplier

Callable returning a WebElement.

required
text str

The text to type.

required

Returns: Self: The current step instance for chaining.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_steps.py
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
@final
@Context.traced
def typing_once(self, element_supplier: ElementSupplier, text: str) -> Self:
    """
    Types the given text into the element supplied by the callable.

    Args:
        element_supplier (ElementSupplier): Callable returning a WebElement.
        text (str): The text to type.
    Returns:
        Self: The current step instance for chaining.
    """
    element = element_supplier()
    element.clear()
    element.send_keys(text)
    return self

SeleniumTests

Bases: AbstractTestsBase[TSteps, TConfiguration]

Base class for Selenium-based UI test cases.

This class manages the lifecycle of a Selenium WebDriver for each test method. It is generic over the types of steps and configuration used.

Attributes:

Name Type Description
_web_driver WebDriver

The Selenium WebDriver instance (not thread safe).

Type Parameters

TSteps: The type of the steps class, typically derived from SeleniumSteps. TConfiguration: The type of the configuration class, typically derived from SeleniumConfiguration.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_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
class SeleniumTests[
    TSteps: SeleniumSteps[Any],
    TConfiguration: SeleniumConfiguration
](AbstractTestsBase[TSteps, TConfiguration]):
    """
    Base class for Selenium-based UI test cases.

    This class manages the lifecycle of a Selenium WebDriver for each test method.
    It is generic over the types of steps and configuration used.

    Attributes:
        _web_driver (WebDriver): The Selenium WebDriver instance (not thread safe).

    Type Parameters:
        TSteps: The type of the steps class, typically derived from SeleniumSteps.
        TConfiguration: The type of the configuration class, typically derived from SeleniumConfiguration.
    """
    _web_driver: WebDriver  # not thread safe

    @property
    def web_driver(self) -> WebDriver:
        '''
        Returns the web driver instance.

        Returns:
            WebDriver: The web driver instance.
        '''
        return self._web_driver

    @override
    def setup_method(self):
        '''
        Initializes the Selenium WebDriver before each test method.
        '''
        super().setup_method()

        options = Options()
        options.add_argument("--start-maximized")  # type: ignore
        self._web_driver = Chrome(
            options,
            self._configuration.service)

    @override
    def teardown_method(self):
        '''
        Quits the Selenium WebDriver after each test method.
        '''
        try:
            self._web_driver.quit()
        finally:
            super().teardown_method()

web_driver property

Returns the web driver instance.

Returns:

Name Type Description
WebDriver WebDriver

The web driver instance.

setup_method()

Initializes the Selenium WebDriver before each test method.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_tests.py
44
45
46
47
48
49
50
51
52
53
54
55
@override
def setup_method(self):
    '''
    Initializes the Selenium WebDriver before each test method.
    '''
    super().setup_method()

    options = Options()
    options.add_argument("--start-maximized")  # type: ignore
    self._web_driver = Chrome(
        options,
        self._configuration.service)

teardown_method()

Quits the Selenium WebDriver after each test method.

Source code in qa-pytest-webdriver/src/qa_pytest_webdriver/selenium_tests.py
57
58
59
60
61
62
63
64
65
@override
def teardown_method(self):
    '''
    Quits the Selenium WebDriver after each test method.
    '''
    try:
        self._web_driver.quit()
    finally:
        super().teardown_method()