Skip to content

Commit 6adba2d

Browse files
author
dmy.berezovskyi
committed
fix qodana
1 parent 8139d99 commit 6adba2d

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

src/screens/element_interactor.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from selenium.common.exceptions import TimeoutException, NoSuchElementException
1313

1414
Locator = Tuple[str, str]
15+
type Condition = Literal["clickable", "visible", "present"]
1516

1617

1718
class WaitType(Enum):
@@ -32,14 +33,15 @@ def __init__(self, driver):
3233
self.waiters[WaitType.FLUENT] = WebDriverWait(
3334
driver, WaitType.FLUENT.value, poll_frequency=1
3435
)
35-
36+
3637
def _get_waiter(self, wait_type: Optional[WaitType] = None) -> WebDriverWait:
38+
"""Returns the appropriate waiter based on the given wait_type."""
3739
return self.waiters.get(wait_type, self.waiters[WaitType.DEFAULT])
3840

3941
def wait_for(
4042
self,
4143
locator: Locator,
42-
condition: Literal["clickable", "visible", "present"] = "visible",
44+
condition: Condition = "visible",
4345
waiter: Optional[WebDriverWait] = None,
4446
) -> WebElement:
4547
waiter = waiter or self._get_waiter()
@@ -61,7 +63,7 @@ def element(
6163
self,
6264
locator: Locator,
6365
n: int = 3,
64-
condition: Literal["clickable", "visible", "present"] = "visible",
66+
condition: Condition = "visible",
6567
wait_type: Optional[WaitType] = WaitType.DEFAULT,
6668
):
6769
for attempt in range(1, n + 1):
@@ -80,7 +82,7 @@ def elements(
8082
self,
8183
locator: Locator,
8284
n: int = 3,
83-
condition: Literal["clickable", "visible", "present"] = "visible",
85+
condition: Condition = "visible",
8486
wait_type: Optional[WaitType] = WaitType.DEFAULT,
8587
) -> List[WebElement]:
8688
for attempt in range(1, n + 1):
@@ -100,7 +102,7 @@ def is_displayed(
100102
locator: Locator,
101103
expected: bool = True,
102104
n: int = 3,
103-
condition: Literal["clickable", "visible", "present"] = "visible",
105+
condition: Condition = "visible",
104106
wait_type: Optional[WaitType] = None,
105107
) -> None:
106108
wait_type = wait_type or WaitType.DEFAULT
@@ -125,7 +127,7 @@ def is_exist(
125127
locator: Locator,
126128
expected: bool = True,
127129
n: int = 3,
128-
condition: Literal["clickable", "visible", "present"] = "visible",
130+
condition: Condition = "visible",
129131
wait_type: Optional[WaitType] = WaitType.SHORT,
130132
retry_delay: float = 0.5,
131133
) -> bool:

0 commit comments

Comments
 (0)