Skip to content

Commit ebc7e3b

Browse files
author
dmy.berezovskyi
committed
added element_interactor.py
1 parent 7148434 commit ebc7e3b

2 files changed

Lines changed: 17 additions & 11 deletions

File tree

conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ def device(request):
5050
@pytest.fixture(scope="function")
5151
def driver(request):
5252
platform = request.config.getoption("--platform")
53+
driver = None
54+
5355
try:
5456
driver = Driver.get_driver(platform)
5557
except Exception as e:
5658
pytest.fail(f"Failed to initialize driver: {e}")
5759

5860
yield driver
61+
5962
if driver is not None:
6063
driver.quit()
64+

src/screens/element_interactor.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,16 +151,16 @@ def _check_elements_displayed(
151151
if index is None:
152152
return all(e.is_displayed() == expected for e in elements)
153153
return elements[index].is_displayed() == expected
154-
154+
155155
def is_displayed(
156-
self,
157-
locator: Locator,
158-
expected: bool = True,
159-
n: int = 3,
160-
condition: Literal["clickable", "visible", "present"] = "visible",
161-
wait_type: Optional[WaitType] = None,
156+
self,
157+
locator: Locator,
158+
expected: bool = True,
159+
n: int = 3,
160+
condition: Literal["clickable", "visible", "present"] = "visible",
161+
wait_type: Optional[WaitType] = None,
162162
) -> None:
163-
""" Checks for an element to be displayed or not, and asserts the visibility.
163+
"""Checks for an element to be displayed or not, and asserts the visibility.
164164
165165
:param locator: A tuple containing the strategy and value of the element locator.
166166
:param expected: The expected visibility status of the element (True or False).
@@ -172,12 +172,14 @@ def is_displayed(
172172
wait_type = wait_type or WaitType.DEFAULT
173173
for _ in range(n):
174174
try:
175-
element = self.wait_for(locator, condition = condition, waiter = self._get_waiter(wait_type))
176-
assert element.is_displayed()==expected
175+
element = self.wait_for(
176+
locator, condition=condition, waiter=self._get_waiter(wait_type)
177+
)
178+
assert element.is_displayed() == expected
177179
return
178180
except Exception:
179181
time.sleep(0.5)
180-
assert False==expected
182+
assert False == expected
181183

182184
def is_exist(
183185
self,

0 commit comments

Comments
 (0)