diff --git a/tests/selenium_tests.py b/tests/selenium_tests.py index 110339f..f66ec78 100644 --- a/tests/selenium_tests.py +++ b/tests/selenium_tests.py @@ -2,6 +2,7 @@ import os from selenium.webdriver.chrome.options import Options +from testui.elements.testui_element import e from testui.support import logger from testui.support.appium_driver import NewDriver from testui.support.testui_driver import TestUIDriver @@ -37,6 +38,10 @@ def test_template_matching(self, selenium_driver: TestUIDriver): selenium_driver.find_image_match( image_compare, 0.1, True, image_match=image_result ) + e(selenium_driver, 'xpath', '//h3[contains(text(), "Image Recognition:")]')\ + .wait_until_visible().press_hold_for() + e(selenium_driver, 'xpath', '//h3[contains(text(), "Image Recognition:")]')\ + .swipe(start_x=50, start_y=50, end_x=100, end_y=100) selenium_driver.raise_errors() @pytest.mark.signup diff --git a/testui/elements/testui_element.py b/testui/elements/testui_element.py index 7fe2041..eb01027 100644 --- a/testui/elements/testui_element.py +++ b/testui/elements/testui_element.py @@ -512,7 +512,7 @@ def press_hold_for(self, milliseconds=1000): err = None while time.time() < start + timeout: try: - actions = self.driver.actions() + actions = self.testui_driver.actions() actions.w3c_actions.pointer_action.click_and_hold(self.get_element()) actions.w3c_actions.pointer_action.pause(milliseconds // 1000) actions.w3c_actions.pointer_action.release() @@ -724,33 +724,27 @@ def swipe( end_x = location2.x if end_y is None: end_y = location2.y - - actions = self.driver.actions() - actions.w3c_actions.pointer_action.move_to_location(x=start_x, y=start_y) - actions.w3c_actions.pointer_action.pointer_down() - if duration: - actions.w3c_actions.pointer_action.pause(duration) - actions.w3c_actions.pointer_action.move_to_location(x=end_x, y=end_y) - actions.w3c_actions.pointer_action.release() - actions.perform() else: if end_x is None: end_x = location.x if end_y is None: end_y = location.y - self.driver.swipe( - start_y=start_y, - start_x=start_x, - end_y=end_y, - end_x=end_x, - duration=duration, - ) + + actions = self.testui_driver.actions() + actions.w3c_actions.pointer_action.move_to_location(x=start_x, y=start_y) + actions.w3c_actions.pointer_action.pointer_down() + if duration: + actions.w3c_actions.pointer_action.pause(duration) + actions.w3c_actions.pointer_action.move_to_location(x=end_x, y=end_y) + actions.w3c_actions.pointer_action.release() + actions.perform() return self except Exception as error: err = error return self.__show_error( - f"{logger.bcolors.FAIL}{err} {self.device_name}: Element not found " - f'with the following locator: "{self.locator_type}:{self.locator}" ' + f"{logger.bcolors.FAIL}{err} {self.device_name}: Error swiping " + f'with the following locator: "{self.locator_type}:{self.locator}", ' + f'with the following coordinates "{start_x}", "{start_y}", "{end_x}", "{end_y}"' f"after {time.time() - start}s {logger.bcolors.ENDC}" ) diff --git a/testui/support/appium_driver.py b/testui/support/appium_driver.py index 28cf70d..ff80534 100644 --- a/testui/support/appium_driver.py +++ b/testui/support/appium_driver.py @@ -342,8 +342,6 @@ def __set_ios_caps(self): self.__desired_capabilities["appium:app"] = self.__app_path if self.__bundle_id is not None: self.__desired_capabilities["appium:bundleId"] = self.__bundle_id - if self.__version is None: - self.__desired_capabilities["appium:platformVersion"] = "15.5" def __set_selenium_caps(self): """Sets the selenium capabilities""" @@ -565,7 +563,7 @@ def __local_run(url, desired_caps, use_port, udid, log_file): logger.log(f"running: appium -p {str(port)}") if udid is None: desired_caps = __set_android_device(desired_caps, device) - logger.log(f'setting device for automation: {desired_caps["udid"]}') + logger.log(f'setting device for automation: {desired_caps["appium:udid"]}') log_dir = os.path.join("./logs", "appium_logs") Path(log_dir).mkdir(parents=True, exist_ok=True) file_path: str @@ -665,7 +663,7 @@ def __set_android_device(desired_caps, number: int): :param number: device index :return: desired capabilities """ - desired_caps["udid"] = get_device_udid(number) + desired_caps["appium:udid"] = get_device_udid(number) return desired_caps