diff --git a/README.md b/README.md index 6cbcab92..a26ab280 100755 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ -

Example: test_demo_site.py from ./examples/ (Uses --chrome by default)

+

Example: test_demo_site.py from ./examples/ (Uses --chrome by default)

```bash cd examples/ @@ -98,7 +98,7 @@ cd examples/ pytest test_coffee_cart.py --demo ``` -

(--demo mode slows down tests and highlights actions)

+

(--demo mode slows down tests and highlights actions)

SeleniumBase Coffee Cart Test

@@ -132,29 +132,29 @@ class CoffeeCartTest(BaseCase): โ–ถ๏ธ How is SeleniumBase different from raw Selenium? (click to expand)
-

๐Ÿ’ก SeleniumBase is a Python framework for browser automation and testing. SeleniumBase uses Selenium/WebDriver APIs, and incorporates test-runners such as pytest, pynose, and behave to provide organized structure, test discovery, test execution, test state (eg. passed, failed, or skipped), and command-line options for changing default settings (such as choosing the browser to use). With raw Selenium, you would need to set up your own options-parser for configuring tests from the command-line.

+

๐Ÿ’ก SeleniumBase is a Python framework for browser automation and testing. SeleniumBase uses Selenium/WebDriver APIs, and incorporates test-runners such as pytest, pynose, and behave to provide organized structure, test discovery, test execution, test state (eg. passed, failed, or skipped), and command-line options for changing default settings (such as choosing the browser to use). With raw Selenium, you would need to set up your own options-parser for configuring tests from the command-line.

-

๐Ÿ’ก With raw Selenium, commands that use selectors need to specify the type of selector (eg. "css selector", "button#myButton"). With SeleniumBase, there's auto-detection between CSS Selectors and XPath, which means you don't need to specify the type of selector in your commands (but optionally you could).

+

๐Ÿ’ก With raw Selenium, commands that use selectors need to specify the type of selector (eg. "css selector", "button#myButton"). With SeleniumBase, there's auto-detection between CSS Selectors and XPath, which means you don't need to specify the type of selector in your commands (but optionally you could).

-

๐Ÿ’ก SeleniumBase methods often perform multiple actions in a single method call. For example, self.type(selector,text) does the following:
1. Waits for the element to be visible.
2. Waits for the element to be interactive.
3. Clears the text field.
4. Types in the new text.
5. Presses Enter/Submit if the text ends in "\n".
With raw Selenium, those actions require multiple method calls.

+

๐Ÿ’ก SeleniumBase methods often perform multiple actions in a single method call. For example, self.type(selector,text) does the following:
1. Waits for the element to be visible.
2. Waits for the element to be interactive.
3. Clears the text field.
4. Types in the new text.
5. Presses Enter/Submit if the text ends in "\n".
With raw Selenium, those actions require multiple method calls.

๐Ÿ’ก SeleniumBase uses default timeout values when not set:
-โœ…self.click("button")
+โœ…self.click("button")
With raw Selenium, methods would fail instantly (by default) if an element needed more time to load:
-โŒself.driver.find_element(by="css selector", value="button").click()
+โŒself.driver.find_element(by="css selector", value="button").click()
(Reliable code is better than unreliable code.)

๐Ÿ’ก SeleniumBase lets you change the explicit timeout values of methods:
-โœ…self.click("button",timeout=10)
+โœ…self.click("button",timeout=10)
With raw Selenium, that requires more code:
-โŒWebDriverWait(driver,10).until(EC.element_to_be_clickable("css selector", "button")).click()
+โŒWebDriverWait(driver,10).until(EC.element_to_be_clickable("css selector", "button")).click()
(Simple code is better than complex code.)

๐Ÿ’ก SeleniumBase gives you clean error output when a test fails. With raw Selenium, error messages can get very messy.

-

๐Ÿ’ก SeleniumBase gives you the option to generate a dashboard and reports for tests. It also saves screenshots from failing tests to the ./latest_logs/ folder. Raw Selenium does not have these options out-of-the-box.

+

๐Ÿ’ก SeleniumBase gives you the option to generate a dashboard and reports for tests. It also saves screenshots from failing tests to the ./latest_logs/ folder. Raw Selenium does not have these options out-of-the-box.

-

๐Ÿ’ก SeleniumBase includes desktop GUI apps for running tests, such as SeleniumBase Commander for pytest and SeleniumBase Behave GUI for behave.

+

๐Ÿ’ก SeleniumBase includes desktop GUI apps for running tests, such as SeleniumBase Commander for pytest and SeleniumBase Behave GUI for behave.

๐Ÿ’ก SeleniumBase has its own Recorder / Test Generator that can create tests from manual browser actions. SeleniumBase also includes other useful tools and console scripts for getting things done quickly. (See the documentation for more details!)

@@ -185,7 +185,7 @@ class TestMFALogin(BaseCase): self.save_screenshot_to_logs() ``` -

๐Ÿ“—๐Ÿ“ An example test with the sb pytest fixture. Runs with pytest.

+

๐Ÿ“—๐Ÿ“ An example test with the sb pytest fixture. Runs with pytest.

```python def test_mfa_login(sb): @@ -199,7 +199,7 @@ def test_mfa_login(sb): sb.save_screenshot_to_logs() ``` -

๐Ÿ“™๐Ÿ“ An example test with the SB Context Manager. Runs with pure python.

+

๐Ÿ“™๐Ÿ“ An example test with the SB Context Manager. Runs with pure python.

```python from seleniumbase import SB @@ -217,7 +217,7 @@ with SB() as sb: # By default, browser="chrome" if not set. sb.assert_exact_text("You have been signed out!", "#top_message") ``` -

๐Ÿ“•๐Ÿ“ An example test with behave-BDD Gherkin structure. Runs with behave. (Learn more)

+

๐Ÿ“•๐Ÿ“ An example test with behave-BDD Gherkin structure. Runs with behave. (Learn more)

```gherkin Feature: SeleniumBase scenarios for the RealWorld App @@ -461,7 +461,7 @@ self.assert_no_js_errors() # Verify there are no JS errors. self.type("input", "dogs\n") # (The "\n" presses ENTER) ``` -Most SeleniumBase scripts can be run with pytest, pynose, or pure python. Not all test runners can run all test formats. For example, tests that use the ``sb`` pytest fixture can only be run with ``pytest``. (See Syntax Formats) There's also a Gherkin test format that runs with behave. +Most SeleniumBase scripts can be run with pytest, pynose, or pure python. Not all test runners can run all test formats. For example, tests that use the ``sb`` pytest fixture can only be run with ``pytest``. (See Syntax Formats) There's also a Gherkin test format that runs with behave. ```bash pytest coffee_cart_tests.py --rs @@ -478,20 +478,20 @@ behave realworld.feature behave calculator.feature -D rs -D dashboard ``` -

โœ… pytest includes automatic test discovery. If you don't specify a specific file or folder to run, pytest will automatically search through all subdirectories for tests to run based on the following criteria:

+

โœ… pytest includes automatic test discovery. If you don't specify a specific file or folder to run, pytest will automatically search through all subdirectories for tests to run based on the following criteria:

* Python files that start with ``test_`` or end with ``_test.py``. * Python methods that start with ``test_``. With a SeleniumBase [pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/pytest.ini) file present, you can modify default discovery settings. The Python class name can be anything because ``seleniumbase.BaseCase`` inherits ``unittest.TestCase`` to trigger autodiscovery. -

โœ… You can do a pre-flight check to see which tests would get discovered by pytest before the real flight:

+

โœ… You can do a pre-flight check to see which tests would get discovered by pytest before the real flight:

```bash pytest --collect-only -q ``` -

โœ… You can be more specific when calling pytest or pynose on a file:

+

โœ… You can be more specific when calling pytest or pynose on a file:

```bash pytest [FILE_NAME.py]::[CLASS_NAME]::[METHOD_NAME] @@ -499,7 +499,7 @@ pytest [FILE_NAME.py]::[CLASS_NAME]::[METHOD_NAME] pynose [FILE_NAME.py]:[CLASS_NAME].[METHOD_NAME] ``` -

โœ… No More Flaky Tests! SeleniumBase methods automatically wait for page elements to finish loading before interacting with them (up to a timeout limit). This means you no longer need random time.sleep() statements in your scripts.

+

โœ… No More Flaky Tests! SeleniumBase methods automatically wait for page elements to finish loading before interacting with them (up to a timeout limit). This means you no longer need random time.sleep() statements in your scripts.

NO MORE FLAKY TESTS! โœ… SeleniumBase supports all major browsers and operating systems: @@ -560,7 +560,7 @@ pytest test_coffee_cart.py --trace

๐Ÿ”ต Command-line Options:

-โœ… Here are some useful command-line options that come with pytest: +โœ… Here are some useful command-line options that come with pytest: ```bash -v # Verbose mode. Prints the full name of each test and shows more details. @@ -577,7 +577,7 @@ pytest test_coffee_cart.py --trace ``` -โœ… SeleniumBase provides additional pytest command-line options for tests: +โœ… SeleniumBase provides additional pytest command-line options for tests: ```bash --browser=BROWSER # (The web browser to use. Default: "chrome".) @@ -923,7 +923,7 @@ pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1

Handling Pop-Up / Pop Up Alerts:

-๐Ÿ”ต self.accept_alert() automatically waits for and accepts alert pop-ups. self.dismiss_alert() automatically waits for and dismisses alert pop-ups. On occasion, some methods like self.click(SELECTOR) might dismiss a pop-up on its own because they call JavaScript to make sure that the readyState of the page is complete before advancing. If you're trying to accept a pop-up that got dismissed this way, use this workaround: Call self.find_element(SELECTOR).click() instead, (which will let the pop-up remain on the screen), and then use self.accept_alert() to accept the pop-up (more on that here). If pop-ups are intermittent, wrap code in a try/except block. +๐Ÿ”ต self.accept_alert() automatically waits for and accepts alert pop-ups. self.dismiss_alert() automatically waits for and dismisses alert pop-ups. On occasion, some methods like self.click(SELECTOR) might dismiss a pop-up on its own because they call JavaScript to make sure that the readyState of the page is complete before advancing. If you're trying to accept a pop-up that got dismissed this way, use this workaround: Call self.find_element(SELECTOR).click() instead, (which will let the pop-up remain on the screen), and then use self.accept_alert() to accept the pop-up (more on that here). If pop-ups are intermittent, wrap code in a try/except block.

Building Guided Tours for Websites:

@@ -949,7 +949,7 @@ pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1
  • If you're using the SeleniumBase MySQL feature to save results from tests running on a server machine, you can install MySQL Workbench to help you read & write from your DB more easily.
  • -
  • If you're using AWS, you can set up an Amazon S3 account for saving log files and screenshots from your tests. To activate this feature, modify settings.py with connection details in the S3 section, and add --with-s3-logging on the command-line when running your tests.
  • +
  • If you're using AWS, you can set up an Amazon S3 account for saving log files and screenshots from your tests. To activate this feature, modify settings.py with connection details in the S3 section, and add --with-s3-logging on the command-line when running your tests.
  • Here's an example of running tests with some additional features enabled: @@ -980,7 +980,7 @@ self.get_current_url() # This method returns the current page URL. self.get_page_source() # This method returns the current page source. ``` -ProTipโ„ข: You can use the self.get_page_source() method with Python's find() command to parse through HTML to find something specific. (For more advanced parsing, see the BeautifulSoup example.) +ProTipโ„ข: You can use the self.get_page_source() method with Python's find() command to parse through HTML to find something specific. (For more advanced parsing, see the BeautifulSoup example.) ```python source = self.get_page_source() @@ -1001,13 +1001,13 @@ self.click("div#my_id") ๐Ÿ”ต **Typing Text:** -self.type(selector, text) # updates the text from the specified element with the specified value. An exception is raised if the element is missing or if the text field is not editable. Example: +self.type(selector, text) # updates the text from the specified element with the specified value. An exception is raised if the element is missing or if the text field is not editable. Example: ```python self.type("input#id_value", "2012") ``` -You can also use self.add_text() or the WebDriver .send_keys() command, but those won't clear the text box first if there's already text inside. +You can also use self.add_text() or the WebDriver .send_keys() command, but those won't clear the text box first if there's already text inside. ๐Ÿ”ต **Getting the text from an element on a page:** @@ -1109,7 +1109,7 @@ if self.is_text_visible("You Shall Not Pass!", "h1"):
    - โ–ถ๏ธ Click for a longer example of is_text_visible(): + โ–ถ๏ธ Click for a longer example of is_text_visible(): ```python def get_mirror_universe_captain_picard_superbowl_ad(superbowl_year): @@ -1149,7 +1149,7 @@ if self.is_link_text_visible("Stop! Hammer time!"):

    ๐Ÿ”ต Switching Tabs:

    -

    If your test opens up a new tab/window, you can switch to it. (SeleniumBase automatically switches to new tabs that don't open to about:blank URLs.)

    +

    If your test opens up a new tab/window, you can switch to it. (SeleniumBase automatically switches to new tabs that don't open to about:blank URLs.)

    ```python self.switch_to_window(1) # This switches to the new tab (0 is the first one) @@ -1238,7 +1238,7 @@ self.execute_script('''document.body.innerHTML = \"%s\"''' % referral_link) self.click("a.analytics") # Clicks the generated button ``` -(Due to popular demand, this traffic generation example has been included in SeleniumBase with the self.generate_referral(start_page, end_page) and the self.generate_traffic(start_page, end_page, loops) methods.) +(Due to popular demand, this traffic generation example has been included in SeleniumBase with the self.generate_referral(start_page, end_page) and the self.generate_traffic(start_page, end_page, loops) methods.)
    @@ -1263,8 +1263,8 @@ class MyTestClass(BaseCase): self.process_deferred_asserts() ``` -deferred_assert_element() and deferred_assert_text() will save any exceptions that would be raised. -To flush out all the failed deferred asserts into a single exception, make sure to call self.process_deferred_asserts() at the end of your test method. If your test hits multiple pages, you can call self.process_deferred_asserts() before navigating to a new page so that the screenshot from your log files matches the URL where the deferred asserts were made. +deferred_assert_element() and deferred_assert_text() will save any exceptions that would be raised. +To flush out all the failed deferred asserts into a single exception, make sure to call self.process_deferred_asserts() at the end of your test method. If your test hits multiple pages, you can call self.process_deferred_asserts() before navigating to a new page so that the screenshot from your log files matches the URL where the deferred asserts were made.

    ๐Ÿ”ต How to access raw WebDriver:

    @@ -1280,13 +1280,13 @@ self.driver.find_elements("partial link text", "GitHub")

    ๐Ÿ”ต How to retry failing tests automatically:

    -

    You can use pytest --reruns=NUM to retry failing tests that many times. Add --reruns-delay=SECONDS to wait that many seconds between retries. Example:

    +

    You can use pytest --reruns=NUM to retry failing tests that many times. Add --reruns-delay=SECONDS to wait that many seconds between retries. Example:

    ```bash pytest --reruns=1 --reruns-delay=1 ``` -

    You can use the @retry_on_exception() decorator to retry failing methods. (First import: from seleniumbase import decorators). To learn more about SeleniumBase decorators, click here.

    +

    You can use the @retry_on_exception() decorator to retry failing methods. (First import: from seleniumbase import decorators). To learn more about SeleniumBase decorators, click here.

    -------- diff --git a/help_docs/behave_gui.md b/help_docs/behave_gui.md index c0acff42..b52f29f7 100644 --- a/help_docs/behave_gui.md +++ b/help_docs/behave_gui.md @@ -2,7 +2,7 @@ ## [](https://github.com/seleniumbase/SeleniumBase/) SeleniumBase Behave GUI / Commander ๐Ÿ๐ŸŽ–๏ธ -๐Ÿ๐ŸŽ–๏ธ The SeleniumBase Behave GUI lets you run behave scripts from a Desktop GUI.
    +๐Ÿ๐ŸŽ–๏ธ The SeleniumBase Behave GUI lets you run behave scripts from a Desktop GUI.
    ๐Ÿ๐ŸŽ–๏ธ To launch it, call ``sbase behave-gui`` or ``sbase gui-behave``: @@ -13,7 +13,7 @@ -๐Ÿ๐ŸŽ–๏ธ SeleniumBase Behave GUI loads the same tests that are found by: +๐Ÿ๐ŸŽ–๏ธ SeleniumBase Behave GUI loads the same tests that are found by: ```bash behave -d @@ -34,7 +34,7 @@ sbase behave-gui features/ # tests located in the "features/" folder sbase behave-gui features/calculator.feature # tests in that feature ``` -๐Ÿ๐ŸŽ–๏ธ Once launched, you can further customize which tests to run and what settings to use. There are various controls for changing settings, modes, and other "behave" command line options that are specific to SeleniumBase. You can also set additional options that don't have a visible toggle. When you're ready to run the selected tests with the specified options, click on the Run Selected Tests button. +๐Ÿ๐ŸŽ–๏ธ Once launched, you can further customize which tests to run and what settings to use. There are various controls for changing settings, modes, and other "behave" command line options that are specific to SeleniumBase. You can also set additional options that don't have a visible toggle. When you're ready to run the selected tests with the specified options, click on the Run Selected Tests button. ๐Ÿโšช With the Dashboard enabled, you'll get one of these: diff --git a/help_docs/commander.md b/help_docs/commander.md index 8ae395b0..9336b5b7 100644 --- a/help_docs/commander.md +++ b/help_docs/commander.md @@ -2,7 +2,7 @@ ## [](https://github.com/seleniumbase/SeleniumBase/) SeleniumBase Commander ๐ŸŽ–๏ธ -๐ŸŽ–๏ธ SeleniumBase Commander lets you run pytest scripts from a Desktop GUI.
    +๐ŸŽ–๏ธ SeleniumBase Commander lets you run pytest scripts from a Desktop GUI.
    ๐ŸŽ–๏ธ To launch it, call ``sbase commander`` or ``sbase gui``: @@ -13,7 +13,7 @@ sbase gui -๐ŸŽ–๏ธ SeleniumBase Commander loads the same tests that are found by: +๐ŸŽ–๏ธ SeleniumBase Commander loads the same tests that are found by: ```bash pytest --co -q @@ -36,7 +36,7 @@ sbase gui test_suite.py sbase gui offline_examples/ ``` -๐ŸŽ–๏ธ Once launched, you can further customize which tests to run and what settings to use. There are various controls for changing settings, modes, and other pytest command line options that are specific to SeleniumBase. You can also set additional options that don't have a visible toggle. When you're ready to run the selected tests with the specified options, click on the Run Selected Tests button. +๐ŸŽ–๏ธ Once launched, you can further customize which tests to run and what settings to use. There are various controls for changing settings, modes, and other pytest command line options that are specific to SeleniumBase. You can also set additional options that don't have a visible toggle. When you're ready to run the selected tests with the specified options, click on the Run Selected Tests button. -------- diff --git a/help_docs/customizing_test_runs.md b/help_docs/customizing_test_runs.md index 3bba9f1e..6bb47c62 100644 --- a/help_docs/customizing_test_runs.md +++ b/help_docs/customizing_test_runs.md @@ -251,7 +251,7 @@ pytest -n8

    How to retry failing tests automatically:

    -

    You can use pytest --reruns=NUM to retry failing tests that many times. Add --reruns-delay=SECONDS to wait that many seconds between retries. Example:

    +

    You can use pytest --reruns=NUM to retry failing tests that many times. Add --reruns-delay=SECONDS to wait that many seconds between retries. Example:

    ```bash pytest --reruns=1 --reruns-delay=1 @@ -293,10 +293,10 @@ There's more info on that here: [pytest-xdist](https://pypi.org/project/pytest-x * ``-n8 --dist=loadfile``: Tests are grouped by their containing file. Groups are distributed to available workers as whole units. This guarantees that all tests in a file run in the same worker.
    - โ–ถ๏ธ -n8 --dist=loadgroup (click to expand) + โ–ถ๏ธ -n8 --dist=loadgroup (click to expand)
    -
    • Tests are grouped by the xdist_group mark. Groups are distributed to available workers as whole units. This guarantees that all tests with the same xdist_group name run in the same worker.
    +
    • Tests are grouped by the xdist_group mark. Groups are distributed to available workers as whole units. This guarantees that all tests with the same xdist_group name run in the same worker.
    ```python @pytest.mark.xdist_group(name="group1") @@ -309,7 +309,7 @@ class Test: pass ``` -

    This makes test_1 and Test::test_2 run in the same worker. Tests without the xdist_group mark are distributed normally.

    +

    This makes test_1 and Test::test_2 run in the same worker. Tests without the xdist_group mark are distributed normally.

    diff --git a/help_docs/syntax_formats.md b/help_docs/syntax_formats.md index 1b87ea0f..6a94e360 100644 --- a/help_docs/syntax_formats.md +++ b/help_docs/syntax_formats.md @@ -40,7 +40,7 @@

    1. BaseCase direct class inheritance

    -In this format, (which is used by most of the tests in the SeleniumBase examples folder), BaseCase is imported at the top of a Python file, followed by a Python class inheriting BaseCase. Then, any test method defined in that class automatically gains access to SeleniumBase methods, including the setUp() and tearDown() methods that are automatically called for opening and closing web browsers at the start and end of tests. +In this format, (which is used by most of the tests in the SeleniumBase examples folder), BaseCase is imported at the top of a Python file, followed by a Python class inheriting BaseCase. Then, any test method defined in that class automatically gains access to SeleniumBase methods, including the setUp() and tearDown() methods that are automatically called for opening and closing web browsers at the start and end of tests. To run a test of this format, use **``pytest``** or ``pynose``. Adding ``BaseCase.main(__name__, __file__)`` enables ``python`` to run ``pytest`` on your file indirectly. Here's an example: @@ -67,7 +67,7 @@ Using ``BaseCase`` inheritance is a great starting point for anyone learning Sel

    2. BaseCase subclass inheritance

    -There are situations where you may want to customize the setUp and tearDown of your tests. Maybe you want to have all your tests login to a specific web site first, or maybe you want to have your tests report results through an API call depending on whether a test passed or failed. This can be done by creating a subclass of BaseCase and then carefully creating custom setUp() and tearDown() methods that don't overwrite the critical functionality of the default SeleniumBase setUp() and tearDown() methods. Afterwards, your test classes will inherit the subclass of BaseCase with the added functionality, rather than directly inheriting BaseCase itself. Here's an example of that: +There are situations where you may want to customize the setUp and tearDown of your tests. Maybe you want to have all your tests login to a specific web site first, or maybe you want to have your tests report results through an API call depending on whether a test passed or failed. This can be done by creating a subclass of BaseCase and then carefully creating custom setUp() and tearDown() methods that don't overwrite the critical functionality of the default SeleniumBase setUp() and tearDown() methods. Afterwards, your test classes will inherit the subclass of BaseCase with the added functionality, rather than directly inheriting BaseCase itself. Here's an example of that: ```python from seleniumbase import BaseCase @@ -114,7 +114,7 @@ class MyTests(BaseTestCase):

    3. The "sb" pytest fixture (no class)

    -The pytest framework comes with a unique system called fixtures, which replaces import statements at the top of Python files by importing libraries directly into test definitions. More than just being an import, a pytest fixture can also automatically call predefined setUp() and tearDown() methods at the beginning and end of test methods. To work, sb is added as an argument to each test method definition that needs SeleniumBase functionality. This means you no longer need import statements in your Python files to use SeleniumBase. If using other pytest fixtures in your tests, you may need to use the SeleniumBase fixture (instead of BaseCase class inheritance) for compatibility reasons. Here's an example of the sb fixture in a test that does not use Python classes: +The pytest framework comes with a unique system called fixtures, which replaces import statements at the top of Python files by importing libraries directly into test definitions. More than just being an import, a pytest fixture can also automatically call predefined setUp() and tearDown() methods at the beginning and end of test methods. To work, sb is added as an argument to each test method definition that needs SeleniumBase functionality. This means you no longer need import statements in your Python files to use SeleniumBase. If using other pytest fixtures in your tests, you may need to use the SeleniumBase fixture (instead of BaseCase class inheritance) for compatibility reasons. Here's an example of the sb fixture in a test that does not use Python classes: ```python def test_sb_fixture_with_no_class(sb): @@ -129,7 +129,7 @@ def test_sb_fixture_with_no_class(sb):

    4. The "sb" pytest fixture (in class)

    -The sb pytest fixture can also be used inside of a class. There is a slight change to the syntax because that means test methods must also include self in their argument definitions when test methods are defined. (The self argument represents the class object, and is used in every test method that lives inside of a class.) Once again, no import statements are needed in your Python files for this to work. Here's an example of using the sb fixture in a test method that lives inside of a Python class: +The sb pytest fixture can also be used inside of a class. There is a slight change to the syntax because that means test methods must also include self in their argument definitions when test methods are defined. (The self argument represents the class object, and is used in every test method that lives inside of a class.) Once again, no import statements are needed in your Python files for this to work. Here's an example of using the sb fixture in a test method that lives inside of a Python class: ```python class Test_SB_Fixture: @@ -145,7 +145,7 @@ class Test_SB_Fixture:

    5. Page Object Model with BaseCase

    -With SeleniumBase, you can use Page Objects to break out code from tests, but remember, the self variable (from test methods that inherit BaseCase) contains the driver and all other framework-specific variable definitions. Therefore, that self must be passed as an arg into any outside class method in order to call SeleniumBase methods from there. In the example below, the self variable from the test method is passed into the sb arg of the Page Object class method because the self arg of the Page Object class method is already being used for its own class. Every Python class method definition must include the self as the first arg. +With SeleniumBase, you can use Page Objects to break out code from tests, but remember, the self variable (from test methods that inherit BaseCase) contains the driver and all other framework-specific variable definitions. Therefore, that self must be passed as an arg into any outside class method in order to call SeleniumBase methods from there. In the example below, the self variable from the test method is passed into the sb arg of the Page Object class method because the self arg of the Page Object class method is already being used for its own class. Every Python class method definition must include the self as the first arg. ```python from seleniumbase import BaseCase @@ -170,7 +170,7 @@ class MyTests(BaseCase):

    6. Page Object Model with the "sb" fixture

    -This is similar to the classic Page Object Model with BaseCase inheritance, except that this time we pass the sb pytest fixture from the test into the sb arg of the page object class method, (instead of passing self). Now that you're using sb as a pytest fixture, you no longer need to import BaseCase anywhere in your code. See the example below: +This is similar to the classic Page Object Model with BaseCase inheritance, except that this time we pass the sb pytest fixture from the test into the sb arg of the page object class method, (instead of passing self). Now that you're using sb as a pytest fixture, you no longer need to import BaseCase anywhere in your code. See the example below: ```python class LoginPage: @@ -192,7 +192,7 @@ class MyTests:

    7. Using "request" to get "sb" (no class)

    -The pytest request fixture can be used to retrieve other pytest fixtures from within tests, such as the sb fixture. This allows you to have more control over when fixtures get initialized because the fixture no longer needs to be loaded at the very beginning of test methods. This is done by calling request.getfixturevalue('sb') from the test. Here's an example of using the pytest request fixture to load the sb fixture in a test method that does not use Python classes: +The pytest request fixture can be used to retrieve other pytest fixtures from within tests, such as the sb fixture. This allows you to have more control over when fixtures get initialized because the fixture no longer needs to be loaded at the very beginning of test methods. This is done by calling request.getfixturevalue('sb') from the test. Here's an example of using the pytest request fixture to load the sb fixture in a test method that does not use Python classes: ```python def test_request_sb_fixture(request): @@ -210,7 +210,7 @@ def test_request_sb_fixture(request):

    8. Using "request" to get "sb" (in class)

    -The pytest request fixture can also be used to get the sb fixture from inside a Python class. Here's an example of that: +The pytest request fixture can also be used to get the sb fixture from inside a Python class. Here's an example of that: ```python class Test_Request_Fixture: @@ -230,7 +230,7 @@ class Test_Request_Fixture:

    9. Overriding the driver via BaseCase

    -When you want to use SeleniumBase methods via BaseCase, but you want total freedom to control how you spin up your web browsers, this is the format you want. Although SeleniumBase gives you plenty of command-line options to change how your browsers are launched, this format gives you more control when the existing options aren't enough. Here's an example of that: +When you want to use SeleniumBase methods via BaseCase, but you want total freedom to control how you spin up your web browsers, this is the format you want. Although SeleniumBase gives you plenty of command-line options to change how your browsers are launched, this format gives you more control when the existing options aren't enough. Here's an example of that: ```python from selenium import webdriver @@ -398,7 +398,7 @@ class TestWire:

    11. BaseCase with Chinese translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Chinese. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Chinese. Here's an example of that: ```python from seleniumbase.translate.chinese import ็ก’ๆต‹่ฏ•็”จไพ‹ @@ -430,7 +430,7 @@ class ๆˆ‘็š„ๆต‹่ฏ•็ฑป(็ก’ๆต‹่ฏ•็”จไพ‹):

    12. BaseCase with Dutch translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Dutch. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Dutch. Here's an example of that: ```python from seleniumbase.translate.dutch import Testgeval @@ -461,7 +461,7 @@ class MijnTestklasse(Testgeval):

    13. BaseCase with French translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into French. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into French. Here's an example of that: ```python from seleniumbase.translate.french import CasDeBase @@ -492,7 +492,7 @@ class MaClasseDeTest(CasDeBase):

    14. BaseCase with Italian translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Italian. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Italian. Here's an example of that: ```python from seleniumbase.translate.italian import CasoDiProva @@ -523,7 +523,7 @@ class MiaClasseDiTest(CasoDiProva):

    15. BaseCase with Japanese translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Japanese. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Japanese. Here's an example of that: ```python from seleniumbase.translate.japanese import ใ‚ปใƒฌใƒ‹ใ‚ฆใƒ ใƒ†ใ‚นใƒˆใ‚ฑใƒผใ‚น @@ -555,7 +555,7 @@ class ็งใฎใƒ†ใ‚นใƒˆใ‚ฏใƒฉใ‚น(ใ‚ปใƒฌใƒ‹ใ‚ฆใƒ ใƒ†ใ‚นใƒˆใ‚ฑใƒผใ‚น):

    16. BaseCase with Korean translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Korean. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Korean. Here's an example of that: ```python from seleniumbase.translate.korean import ์…€๋ ˆ๋Š„_ํ…Œ์ŠคํŠธ_์ผ€์ด์Šค @@ -585,7 +585,7 @@ class ํ…Œ์ŠคํŠธ_ํด๋ž˜์Šค(์…€๋ ˆ๋Š„_ํ…Œ์ŠคํŠธ_์ผ€์ด์Šค):

    17. BaseCase with Portuguese translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Portuguese. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Portuguese. Here's an example of that: ```python from seleniumbase.translate.portuguese import CasoDeTeste @@ -619,7 +619,7 @@ class MinhaClasseDeTeste(CasoDeTeste):

    18. BaseCase with Russian translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Russian. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Russian. Here's an example of that: ```python from seleniumbase.translate.russian import ะขะตัั‚ะะฐะกะตะปะตะฝ @@ -650,7 +650,7 @@ class ะœะพะนะขะตัั‚ะพะฒั‹ะนะšะปะฐัั(ะขะตัั‚ะะฐะกะตะปะตะฝ):

    19. BaseCase with Spanish translations

    -This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Spanish. Here's an example of that: +This format is similar to the English version with BaseCase inheritance, but there's a different import statement, and method names have been translated into Spanish. Here's an example of that: ```python from seleniumbase.translate.spanish import CasoDePrueba @@ -783,7 +783,7 @@ def login_to_swag_labs(context, user):

    21. SeleniumBase SB (Python context manager)

    -This format provides a pure Python way of using SeleniumBase without a test runner. Options can be passed via method instantiation or from the command-line. When setting the test option to True (or calling python --test), then standard test logging will occur, such as screenshots and reports for failing tests. All the usual SeleniumBase options are available, such as customizing the browser settings, etc. Here are some examples: +This format provides a pure Python way of using SeleniumBase without a test runner. Options can be passed via method instantiation or from the command-line. When setting the test option to True (or calling python --test), then standard test logging will occur, such as screenshots and reports for failing tests. All the usual SeleniumBase options are available, such as customizing the browser settings, etc. Here are some examples: ```python from seleniumbase import SB @@ -803,7 +803,7 @@ with SB() as sb: # By default, browser="chrome" if not set. (See examples/raw_sb.py for the test.) -Here's another example, which uses test mode: +Here's another example, which uses test mode: ```python from seleniumbase import SB @@ -834,7 +834,7 @@ with SB(test=True, rtf=True, demo=True) as sb:

    22. The driver manager (via context manager)

    -This pure Python format gives you a raw webdriver instance in a with block. The SeleniumBase Driver Manager will automatically make sure that your driver is compatible with your browser version. It gives you full access to customize driver options via method args or via the command-line. The driver will automatically call quit() after the code leaves the with block. Here are some examples: +This pure Python format gives you a raw webdriver instance in a with block. The SeleniumBase Driver Manager will automatically make sure that your driver is compatible with your browser version. It gives you full access to customize driver options via method args or via the command-line. The driver will automatically call quit() after the code leaves the with block. Here are some examples: ```python """This script can be run with pure "python". (pytest not needed)."""