Skip to content

Commit 08c3eba

Browse files
author
dmy.berezovskyi
committed
fix qodana
1 parent 6adba2d commit 08c3eba

4 files changed

Lines changed: 15 additions & 20 deletions

File tree

conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ def driver(request):
6262
except Exception as e:
6363
pytest.fail(f"Failed to initialize driver: {e}")
6464

65-
yield driver
65+
yield event_driver
6666

67-
if driver is not None:
68-
driver.quit()
67+
if event_driver is not None:
68+
event_driver.quit()
6969

7070

7171
# def pytest_runtest_makereport(item, call):

src/screens/base_screen.py

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55

66

77
Locator = Tuple[str, str]
8+
type Condition = Literal["clickable", "visible", "present"]
9+
type Direction = Literal["down", "up"]
810

911

1012
class Screen(ElementInteractor):
1113
def __init__(self, driver):
1214
super().__init__(driver)
1315

14-
def click(
15-
self,
16-
locator: Locator,
17-
condition: Literal["clickable", "visible", "present"] = "clickable",
18-
):
16+
def click(self, locator: Locator, condition: Condition = "clickable"):
1917
element = self.element(locator, condition=condition)
2018
element.click()
2119

@@ -61,7 +59,7 @@ def swipe(
6159

6260
def scroll(
6361
self,
64-
directions: Literal["down", "up"] = "down",
62+
directions: Direction = "down",
6563
start_ratio: float = 0.7,
6664
end_ratio: float = 0.3,
6765
):
@@ -111,7 +109,7 @@ def scroll_to_element(
111109
def scroll_until_element_visible(
112110
self,
113111
destination_el: Locator,
114-
directions: Literal["down", "up"] = "down",
112+
directions: Direction = "down",
115113
start_ratio: float = 0.6,
116114
end_ratio: float = 0.3,
117115
retries: int = 1,
@@ -126,10 +124,7 @@ def type(self, locator: Locator, text: str):
126124
element.send_keys(text)
127125

128126
def double_tap(
129-
self,
130-
locator: Locator,
131-
condition: Literal["clickable", "visible", "present"] = "clickable",
132-
**kwargs,
127+
self, locator: Locator, condition: Condition = "clickable", **kwargs
133128
):
134129
"""Double taps on an element."""
135130
try:

src/screens/element_interactor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from selenium.webdriver.common.actions.action_builder import ActionBuilder
88
from selenium.webdriver.common.actions.pointer_input import PointerInput
99
from selenium.webdriver.remote.webelement import WebElement
10-
from selenium.webdriver.support import expected_conditions as EC
10+
from selenium.webdriver.support import expected_conditions as ec
1111
from selenium.webdriver.support.wait import WebDriverWait
1212
from selenium.common.exceptions import TimeoutException, NoSuchElementException
1313

@@ -33,7 +33,7 @@ def __init__(self, driver):
3333
self.waiters[WaitType.FLUENT] = WebDriverWait(
3434
driver, WaitType.FLUENT.value, poll_frequency=1
3535
)
36-
36+
3737
def _get_waiter(self, wait_type: Optional[WaitType] = None) -> WebDriverWait:
3838
"""Returns the appropriate waiter based on the given wait_type."""
3939
return self.waiters.get(wait_type, self.waiters[WaitType.DEFAULT])
@@ -46,9 +46,9 @@ def wait_for(
4646
) -> WebElement:
4747
waiter = waiter or self._get_waiter()
4848
conditions = {
49-
"clickable": EC.element_to_be_clickable(locator),
50-
"visible": EC.visibility_of_element_located(locator),
51-
"present": EC.presence_of_element_located(locator),
49+
"clickable": ec.element_to_be_clickable(locator),
50+
"visible": ec.visibility_of_element_located(locator),
51+
"present": ec.presence_of_element_located(locator),
5252
}
5353
if condition not in conditions:
5454
raise ValueError(f"Unknown condition: {condition}")

tests/test_p1/test_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from screens.main_screen.main_screen import MainScreen
33

44

5-
class TestClick:
5+
class TestBaseActions:
66
@pytest.fixture(autouse=True)
77
def setup(self, driver) -> None:
88
"""Setup common objects for tests after address is set."""

0 commit comments

Comments
 (0)