Skip to content

Commit

Permalink
kwargs
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaymudholkar1 committed Feb 4, 2025
1 parent ec6cfd2 commit bfabd53
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
31 changes: 18 additions & 13 deletions libs/playwright_ops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from itertools import chain
from sys import prefix

from libs import CurrentExecution
Expand Down Expand Up @@ -32,15 +33,12 @@ def capture_screenshot(self, identifier: str, action: str) -> None:
# self.ce.page.set_viewport_size({"width": 1500, "height": 1500}) # Not prudent for mobile screenshots
self.ce.page.screenshot(path=_ss_path, type=screenshot_file_types.JPEG)

def verify(
self,
locator: str,
property: str,
expected_value: str,
exact: bool = False,
by_test_id: bool = False,
chain_locator: bool = False,
) -> None:
def verify(self, locator: str, property: str, expected_value: str, **kwargs) -> None:
# Unpack keyword arguments
exact: bool = kwargs.get("exact", False)
by_test_id: bool = kwargs.get("by_test_id", False)
chain_locator: bool = kwargs.get("chain_locator", False)
# Act
actual_value = self.get_element_property(
locator=locator, property=property, by_test_id=by_test_id, chain_locator=chain_locator
)
Expand Down Expand Up @@ -82,9 +80,12 @@ def verify(
self.capture_screenshot(identifier=locator, action=screenshot_actions.VERIFY_VISIBILITY_FAILED)
assert expected_value == actual_value, f"{locator} is not visible."

def get_element_property(
self, locator: str, property: str, by_test_id: bool = False, chain_locator: bool = False, index: int = 0
) -> str:
def get_element_property(self, locator: str, property: str, **kwargs) -> str:
# Unpack keyword arguments
by_test_id: bool = kwargs.get("by_test_id", False)
chain_locator: bool = kwargs.get("chain_locator", False)
index: int = kwargs.get("index", 0)
# Act
match property:
case element_properties.TEXT:
if by_test_id:
Expand Down Expand Up @@ -127,7 +128,11 @@ def get_element_property(
case element_properties.EXISTS:
return self.ce.page.query_selector(locator) is not None

def act(self, locator, action, value=None, exact: bool = False, index: int = 0) -> None:
def act(self, locator, action, value=None, **kwargs) -> None:
# Unpack keyword arguments
exact: bool = kwargs.get("exact", False)
index: int = kwargs.get("index", 0)
# Act
self.capture_screenshot(identifier=locator, action=f"before-{action}")
match action.lower():
case actions.CLICK_LINK:
Expand Down
1 change: 0 additions & 1 deletion tests/test_50_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ def setup_tests(self, start_mavis: None):

@pytest.mark.e2e
@pytest.mark.order(5001)
# @pytest.mark.skip(reason="Under construction")
def test_e2e(self):
self.dashboard_page.click_programmes()
self.programmes_page.upload_cohorts(file_paths=test_data_file_paths.COHORTS_E2E_1)
Expand Down

0 comments on commit bfabd53

Please sign in to comment.