Skip to content

Commit 025b4c1

Browse files
committed
uv + ruff
1 parent 000acb0 commit 025b4c1

23 files changed

+186
-300
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,14 @@ repos:
88
- id: check-xml
99
- id: end-of-file-fixer
1010
- id: trailing-whitespace
11-
- id: check-docstring-first
12-
- id: name-tests-test
13-
- id: file-contents-sorter
14-
- id: pretty-format-json
15-
args: [ --autofix ]
1611
- id: check-ast
17-
- id: check-builtin-literals
1812
- id: check-case-conflict
1913
- id: check-executables-have-shebangs
2014
- id: check-merge-conflict
2115
- id: check-shebang-scripts-are-executable
22-
- id: debug-statements
2316
- id: detect-private-key
2417
- id: no-commit-to-branch
25-
args: [ '--branch', 'main' ]
18+
args: ['--branch', 'main']
2619
- repo: https://github.com/python-jsonschema/check-jsonschema
2720
rev: 0.32.1
2821
hooks:
@@ -35,33 +28,14 @@ repos:
3528
- id: conventional-pre-commit
3629
stages: [commit-msg]
3730
args: []
38-
- repo: https://github.com/psf/black
39-
rev: 25.1.0
40-
hooks:
41-
- id: black
42-
language_version: python3
43-
args: [ '--config', 'pyproject.toml' ]
44-
- repo: https://github.com/PyCQA/autoflake
45-
rev: v2.3.1
46-
hooks:
47-
- id: autoflake
48-
args:
49-
[
50-
'--in-place',
51-
'--remove-unused-variable',
52-
'--remove-all-unused-imports',
53-
'--expand-star-imports',
54-
'--ignore-init-module-imports',
55-
]
56-
- repo: https://github.com/PyCQA/isort
57-
rev: 6.0.1
58-
hooks:
59-
- id: isort
60-
args: [ '--settings-file', 'pyproject.toml' ]
61-
- repo: https://github.com/asottile/pyupgrade
62-
rev: v3.19.1
63-
hooks:
64-
- id: pyupgrade
31+
- repo: https://github.com/astral-sh/ruff-pre-commit
32+
rev: v0.11.4
33+
hooks:
34+
- id: ruff
35+
args: [ --fix ]
36+
continue_on_error: true
37+
- id: ruff-format
38+
continue_on_error: true
6539
- repo: https://github.com/codespell-project/codespell
6640
rev: v2.4.1
6741
hooks:
@@ -72,11 +46,10 @@ repos:
7246
rev: v0.24.1
7347
hooks:
7448
- id: validate-pyproject
75-
# Optional extra validations from SchemaStore:
76-
additional_dependencies: [ "validate-pyproject-schema-store[all]" ]
49+
additional_dependencies: ["validate-pyproject-schema-store[all]"]
7750
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
7851
rev: v2.14.0
7952
hooks:
8053
- id: pretty-format-toml
8154
exclude: poetry.lock
82-
args: [ --autofix ]
55+
args: [--autofix]

.github/README.md renamed to README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ git clone https://github.com/nirtal85/Selenium-Python-Example.git
5858
cd selenium-python-example
5959
```
6060

61-
### Create and activate a virtual environment then Install project dependencies
61+
### Create and activate a virtual environment then Install project dependencies
6262

6363
#### For Windows:
6464
```bash
@@ -72,7 +72,7 @@ uv pip sync uv.lock
7272
```bash
7373
python3 -m pip install uv
7474
uv venv
75-
source .venv/bin/activate
75+
source .venv/bin/activate
7676
uv pip sync uv.lock
7777
```
7878

pages/about_page.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Tuple
2-
31
import allure
42
from selenium.webdriver.common.by import By
53

@@ -9,8 +7,8 @@
97
class AboutPage(BasePage):
108
"""About page - The first page that appears when navigating to base URL"""
119

12-
LOGIN_LINK: Tuple[str, str] = (By.CSS_SELECTOR, ".login")
13-
REGISTER_LINK: Tuple[str, str] = (By.CSS_SELECTOR, ".register")
10+
LOGIN_LINK: tuple[str, str] = (By.CSS_SELECTOR, ".login")
11+
REGISTER_LINK: tuple[str, str] = (By.CSS_SELECTOR, ".register")
1412

1513
def __init__(self, driver, wait):
1614
super().__init__(driver, wait)

pages/base_page.py

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
from typing import Tuple, Union
2-
31
from deprecated import deprecated
42
from selenium.common.exceptions import NoSuchElementException
53
from selenium.webdriver import ActionChains, Chrome, Edge, Firefox
64
from selenium.webdriver.remote.webelement import WebElement
75
from selenium.webdriver.support import expected_conditions
8-
from selenium.webdriver.support.expected_conditions import (
9-
StaleElementReferenceException,
10-
)
6+
from selenium.webdriver.support.expected_conditions import StaleElementReferenceException
117
from selenium.webdriver.support.wait import WebDriverWait
128

139

1410
class BasePage:
1511
"""Wrapper for selenium operations."""
1612

17-
def __init__(self, driver: Union[Chrome, Firefox, Edge], wait: WebDriverWait):
13+
def __init__(self, driver: Chrome | Firefox | Edge, wait: WebDriverWait):
1814
self.driver = driver
1915
self.wait = wait
2016

@@ -39,42 +35,39 @@ def set_geo_location(self, latitude: float, longitude: float) -> None:
3935
"""Sets the geolocation for the web browser using the Chrome DevTools
4036
Protocol (CDP).
4137
42-
Parameters:
38+
Parameters
39+
----------
4340
- latitude (float): The latitude of the desired geolocation.
4441
- longitude (float): The longitude of the desired geolocation.
4542
46-
Returns:
43+
Returns
44+
-------
4745
None
4846
4947
Note:
5048
This method uses the Chrome DevTools Protocol (CDP) to override the geolocation
5149
in the web browser, allowing simulation of a specific geographic location for testing purposes.
5250
The accuracy is set to 1 for simplicity in this method.
51+
5352
"""
5453
self.driver.execute_cdp_cmd(
5554
"Emulation.setGeolocationOverride",
5655
{"latitude": latitude, "longitude": longitude, "accuracy": 1},
5756
)
5857

59-
def click(self, locator: Tuple[str, str]) -> None:
60-
el: WebElement = self.wait.until(
61-
expected_conditions.element_to_be_clickable(locator)
62-
)
58+
def click(self, locator: tuple[str, str]) -> None:
59+
el: WebElement = self.wait.until(expected_conditions.element_to_be_clickable(locator))
6360
self._highlight_element(el, "green")
6461
el.click()
6562

66-
def fill_text(self, locator: Tuple[str, str], txt: str) -> None:
67-
el: WebElement = self.wait.until(
68-
expected_conditions.element_to_be_clickable(locator)
69-
)
63+
def fill_text(self, locator: tuple[str, str], txt: str) -> None:
64+
el: WebElement = self.wait.until(expected_conditions.element_to_be_clickable(locator))
7065
el.clear()
7166
self._highlight_element(el, "green")
7267
el.send_keys(txt)
7368

74-
def clear_text(self, locator: Tuple[str, str]) -> None:
75-
el: WebElement = self.wait.until(
76-
expected_conditions.element_to_be_clickable(locator)
77-
)
69+
def clear_text(self, locator: tuple[str, str]) -> None:
70+
el: WebElement = self.wait.until(expected_conditions.element_to_be_clickable(locator))
7871
el.clear()
7972

8073
def scroll_to_bottom(self) -> None:
@@ -84,10 +77,8 @@ def submit(self, webelement: WebElement) -> None:
8477
self._highlight_element(webelement, "green")
8578
webelement.submit()
8679

87-
def get_text(self, locator: Tuple[str, str]) -> str:
88-
el: WebElement = self.wait.until(
89-
expected_conditions.visibility_of_element_located(locator)
90-
)
80+
def get_text(self, locator: tuple[str, str]) -> str:
81+
el: WebElement = self.wait.until(expected_conditions.visibility_of_element_located(locator))
9182
self._highlight_element(el, "green")
9283
return el.text
9384

pages/forgot_password_page.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
1-
from typing import Tuple
2-
31
import allure
42
from selenium.webdriver.common.by import By
53

64
from pages.base_page import BasePage
75

86

97
class ForgotPasswordPage(BasePage):
10-
EMAIL_FIELD: Tuple[str, str] = (By.CSS_SELECTOR, "[name=email]")
11-
SEND_PASSWORD_RESET_LINK_BUTTON: Tuple[str, str] = (
8+
EMAIL_FIELD: tuple[str, str] = (By.CSS_SELECTOR, "[name=email]")
9+
SEND_PASSWORD_RESET_LINK_BUTTON: tuple[str, str] = (
1210
By.CSS_SELECTOR,
1311
"[type=submit]",
1412
)
15-
ERROR_MSG: Tuple[str, str] = (By.CSS_SELECTOR, ".alert-danger")
16-
SUCCESS_MSG: Tuple[str, str] = (By.CSS_SELECTOR, ".alert-success")
17-
PAGE_TITLE: Tuple[str, str] = (By.CSS_SELECTOR, ".e-form-heading")
13+
ERROR_MSG: tuple[str, str] = (By.CSS_SELECTOR, ".alert-danger")
14+
SUCCESS_MSG: tuple[str, str] = (By.CSS_SELECTOR, ".alert-success")
15+
PAGE_TITLE: tuple[str, str] = (By.CSS_SELECTOR, ".e-form-heading")
1816

1917
def __init__(self, driver, wait):
2018
super().__init__(driver, wait)

pages/login_page.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Tuple
2-
31
import allure
42
from selenium.webdriver.common.by import By
53

@@ -9,12 +7,12 @@
97
class LoginPage(TopMenuBar):
108
"""Login Page."""
119

12-
USERNAME_FIELD: Tuple[str, str] = (By.CSS_SELECTOR, "input[type=email]")
13-
PASSWORD_FIELD: Tuple[str, str] = (By.CSS_SELECTOR, "input[type=password]")
14-
LOGIN_BUTTON: Tuple[str, str] = (By.CSS_SELECTOR, "button[type=submit]")
15-
LOGIN_ERROR_MESSAGE: Tuple[str, str] = (By.CSS_SELECTOR, "div.alert-danger")
16-
PAGE_TITLE: Tuple[str, str] = (By.CSS_SELECTOR, ".e-form-heading")
17-
FORGOT_PASSWORD_LINK: Tuple[str, str] = (
10+
USERNAME_FIELD: tuple[str, str] = (By.CSS_SELECTOR, "input[type=email]")
11+
PASSWORD_FIELD: tuple[str, str] = (By.CSS_SELECTOR, "input[type=password]")
12+
LOGIN_BUTTON: tuple[str, str] = (By.CSS_SELECTOR, "button[type=submit]")
13+
LOGIN_ERROR_MESSAGE: tuple[str, str] = (By.CSS_SELECTOR, "div.alert-danger")
14+
PAGE_TITLE: tuple[str, str] = (By.CSS_SELECTOR, ".e-form-heading")
15+
FORGOT_PASSWORD_LINK: tuple[str, str] = (
1816
By.CSS_SELECTOR,
1917
"[href='https://app.involve.me/password/reset']",
2018
)

pages/project_edit_page.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Tuple
2-
31
import allure
42
from selenium.webdriver.common.by import By
53

@@ -9,20 +7,20 @@
97
class ProjectEditPage(BasePage):
108
"""Project Edit page - the page where adding to and editing projects is done"""
119

12-
_PROJECT_NAME_FIELD: Tuple[str, str] = (By.CSS_SELECTOR, "input#project-name")
13-
_THANK_YOU_PAGE_TYPE_BUTTON: Tuple[str, str] = (
10+
_PROJECT_NAME_FIELD: tuple[str, str] = (By.CSS_SELECTOR, "input#project-name")
11+
_THANK_YOU_PAGE_TYPE_BUTTON: tuple[str, str] = (
1412
By.CSS_SELECTOR,
1513
"[for=select-single-outcome]",
1614
)
17-
_OUTCOME_PAGES_TYPE_BUTTON: Tuple[str, str] = (
15+
_OUTCOME_PAGES_TYPE_BUTTON: tuple[str, str] = (
1816
By.CSS_SELECTOR,
1917
"[for=select-outcomes]",
2018
)
21-
_START_EDITING_BUTTON: Tuple[str, str] = (
19+
_START_EDITING_BUTTON: tuple[str, str] = (
2220
By.CSS_SELECTOR,
2321
".swal-button.swal-button--confirm",
2422
)
25-
_SAVE_AND_EXIT_BUTTON: Tuple[str, str] = (By.CSS_SELECTOR, ".e-close.nav-link")
23+
_SAVE_AND_EXIT_BUTTON: tuple[str, str] = (By.CSS_SELECTOR, ".e-close.nav-link")
2624

2725
def __init__(self, driver, wait):
2826
super().__init__(driver, wait)

pages/project_type_page.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from typing import Tuple
2-
31
import allure
42
from selenium.webdriver.common.by import By
53
from selenium.webdriver.support import expected_conditions
@@ -10,8 +8,8 @@
108
class ProjectTypePage(TopNavigateBar):
119
"""Project Type page - where one can choose which kind of templates to work with"""
1210

13-
_START_FROM_SCRATCH_BUTTON: Tuple[str, str] = (By.CSS_SELECTOR, ".blank div.icon")
14-
_PROJECTS_BLOCK: Tuple[str, str] = (
11+
_START_FROM_SCRATCH_BUTTON: tuple[str, str] = (By.CSS_SELECTOR, ".blank div.icon")
12+
_PROJECTS_BLOCK: tuple[str, str] = (
1513
By.CSS_SELECTOR,
1614
"#app-layout div:nth-child(3) .title",
1715
)

0 commit comments

Comments
 (0)