Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/selenium_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
32 changes: 13 additions & 19 deletions testui/elements/testui_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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}"
)

Expand Down
6 changes: 2 additions & 4 deletions testui/support/appium_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand Down