Skip to content

Refactor pytest fixtures #510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Refactor pytest fixtures #510

wants to merge 17 commits into from

Conversation

shivahari
Copy link
Collaborator

This PR focuses on refactoring conftest.py module ♻️ by introducing Python dataclass for maintaining configurations.

The dataclass helps group configurations 📃 together and helps remove redundant fixtures.

This change introduces two new configuration modules:

  1. config_store
  2. config_factory

The configuration values are collected in the store module and the factory module presents the conftest with apt configurations to run the following tests:

  1. UI
  2. Mobile
  3. API

This changes out of the box implements dataclass configuration for BrowserStack only for remote test execution. I was not able to test against SauceLabs and hence did not include it.

The test configuration is printed at the start of every test now:

+-----------------------------------------------------------------------------------+
|                                 test_example_table                                |
+---------------------------------------------+-------------------------------------+
|          Parameters                         |          Values                     |
+---------------------------------------------+-------------------------------------+
|          url                                |          https://qxf2.com/          |
|          browser_name                       |          headless-chrome            |
|          browser_version                    |          latest                     |
|          platform_name                      |          windows                    |
|          platform_version                   |          11                         |
|          remote_flag                        |          N                          |
|          browserstack_project_name          |          None                       |
|          browserstack_build_name            |          None                       |
|          testrail_flag                      |          N                          |
|          testrail_test_run_id               |          None                       |
|          tesults_flag                       |          N                          |
+---------------------------------------------+-------------------------------------+

To-Dos after this PR is merged:

  1. Remove the redundant configuration files, they are not needed, now that we have dataclass
  2. Add a method to Zero Page to unpack the dataclass configuration
  3. Replace remaining fixtures with dataclass

@avinash010
Copy link
Collaborator

@shivahari we are getting issues related to driver when running tests in Chrome driver

Python says:Message: Unable to obtain driver for chrome using Selenium Manager.; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors/driver_location

ERROR

@avinash010
Copy link
Collaborator

@shivahari Another issue i see is with the platform_name, though I am running the test in Linux Machine, its printing the platform_name as windows

| test_example_form |
+---------------------------------------------+-------------------------------------+
| Parameters | Values |
+---------------------------------------------+-------------------------------------+
| url | https://qxf2.com/ |
| browser_name | chrome |
| browser_version | None |
| platform_name | windows |
| platform_version | 11 |
| remote_flag | N |
| browserstack_project_name | None |
| browserstack_build_name | None |
| testrail_flag | N |
| testrail_test_run_id | None |
| tesults_flag | N |

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants