From daf19aed97eddf972ba8ec55f3981b4ec7fe281d Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Thu, 7 Dec 2023 12:43:02 +0200 Subject: [PATCH 1/3] upgrade all the dependencies and remove value --- requirements.txt | 13 ++++++------- setup.py | 13 ++++++------- tests/appium_app_test.py | 22 +++++++++++++++++++--- testui/support/appium_driver.py | 9 +++++++-- testui/support/testui_driver.py | 2 ++ tox.ini | 1 - 6 files changed, 40 insertions(+), 20 deletions(-) diff --git a/requirements.txt b/requirements.txt index e69ab46..b59df88 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,15 +4,14 @@ black==22.6.0 build # lib -pytest==6.2.5 -Appium-Python-Client==2.6.0 -selenium==4.1.0 -opencv-python==4.6.0.66 +pytest==7.4.3 +Appium-Python-Client==3.1.0 +selenium==4.16.0 +opencv-python==4.8.1.78 geckodriver-autoinstaller==0.1.0 -value==0.1.0 pytest-xdist==2.5.0 pytest-testrail==2.9.0 pure-python-adb==0.3.0.dev0 -webdriver-manager==3.6.3 -numpy==1.22.0 +webdriver-manager==4.0.1 +numpy==1.26.2 imutils==0.5.4 diff --git a/setup.py b/setup.py index fdbffeb..61365a1 100644 --- a/setup.py +++ b/setup.py @@ -37,17 +37,16 @@ packages=find_packages(), python_requires=">=3.6, <4", install_requires=[ - "pytest==6.2.5", - "Appium-Python-Client==2.6.0", - "selenium==4.1.0", - "opencv-python==4.6.0.66", + "pytest==7.4.3", + "Appium-Python-Client==3.1.0", + "selenium==4.16.0", + "opencv-python==4.8.1.78", "geckodriver-autoinstaller==0.1.0", - "value==0.1.0", "pytest-xdist==2.5.0", "pytest-testrail==2.9.0", "pure-python-adb==0.3.0.dev0", - "webdriver-manager==3.6.3", - "numpy==1.22.0", + "webdriver-manager==4.0.1", + "numpy==1.26.2", "imutils==0.5.4", ], ) diff --git a/tests/appium_app_test.py b/tests/appium_app_test.py index 6813cfe..574cdb0 100644 --- a/tests/appium_app_test.py +++ b/tests/appium_app_test.py @@ -1,6 +1,8 @@ import pytest -from tests.screens.landing import LandingScreen +from selenium.webdriver.common.actions import interaction +from selenium.webdriver.common.actions.pointer_input import PointerInput +from selenium.webdriver.common.actions.action_builder import ActionBuilder from testui.support import logger from testui.support.appium_driver import NewDriver from testui.support.testui_driver import TestUIDriver @@ -24,6 +26,20 @@ def appium_driver(self): @pytest.mark.signup def test_appium_app(self, appium_driver: TestUIDriver): logger.log_test_name("T92701: Check appium app") - landing_page = LandingScreen(appium_driver) - landing_page.i_am_in_google_play_landing_screen() + # Deprecated + # appium_driver.touch_actions().press(x=500, y=10)\ + # .move_to(x=500, y=1000).release().perform() + + appium_driver.actions().w3c_actions = ActionBuilder( + appium_driver.get_driver, + mouse=PointerInput(interaction.POINTER_TOUCH, "touch")) + + actions = appium_driver.actions() + actions.w3c_actions.pointer_action.move_to_location(x=500, y=10) + actions.w3c_actions.pointer_action.pointer_down() + actions.w3c_actions.pointer_action.pause(1) + actions.w3c_actions.pointer_action.move_to_location(x=500, y=1000) + actions.w3c_actions.pointer_action.release() + actions.perform() + appium_driver.raise_errors() diff --git a/testui/support/appium_driver.py b/testui/support/appium_driver.py index a539d66..3a6417f 100644 --- a/testui/support/appium_driver.py +++ b/testui/support/appium_driver.py @@ -1,5 +1,4 @@ import atexit -import datetime import os import subprocess import threading @@ -16,6 +15,9 @@ from selenium.webdriver.firefox.options import Options as FirefoxOptions from selenium import webdriver from webdriver_manager import chrome +from appium.options.android import UiAutomator2Options +from appium.options.ios import XCUITestOptions + from testui.support import logger from testui.support.api_support import get_chrome_version @@ -419,14 +421,17 @@ def start_driver(desired_caps, url, debug, port, udid, log_file): logger.log("starting appium driver...") process = None + options = None if "android" in desired_caps["platformName"].lower(): url, desired_caps, process, file = __local_run( url, desired_caps, port, udid, log_file ) + options = UiAutomator2Options().load_capabilities(desired_caps) else: url, desired_caps, file = __local_run_ios( url, desired_caps, port, udid, log_file ) + options = XCUITestOptions().load_capabilities(desired_caps) err = None for _ in range(2): try: @@ -435,7 +440,7 @@ def start_driver(desired_caps, url, debug, port, udid, log_file): with warnings.catch_warnings(): # To suppress a warning from an issue on selenium side warnings.filterwarnings("ignore", category=DeprecationWarning) - driver = Remote(url, desired_caps) + driver = Remote(url, options=options) atexit.register(__quit_driver, driver, debug) logger.log(f"appium running on {url}. \n") lock.release() diff --git a/testui/support/testui_driver.py b/testui/support/testui_driver.py index 6813838..90add5c 100644 --- a/testui/support/testui_driver.py +++ b/testui/support/testui_driver.py @@ -122,6 +122,8 @@ def remove_log_file(self, when_no_errors=True): def touch_actions(self) -> TouchAction: """ + Deprecated function, soon to be removed, use actions instead. + Will return a TouchAction object for the current driver. This is meant for Appium Drivers only. :return: TouchAction diff --git a/tox.ini b/tox.ini index 68aeaa6..2b07084 100644 --- a/tox.ini +++ b/tox.ini @@ -12,7 +12,6 @@ deps = pytest pytest-xdist selenium - value geckodriver-autoinstaller commands = pytest tests/selenium_tests.py -s From fdab6e0eea1ac75101f05aeea232bcb312326c44 Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Thu, 7 Dec 2023 14:28:07 +0200 Subject: [PATCH 2/3] fix pipeline --- .github/workflows/integration.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 426f0ab..0a2845d 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -27,11 +27,7 @@ jobs: - name: Analysing the code with pylint run: | pylint $(git ls-files '*.py') - - name: Remove Chrome - run: sudo apt purge google-chrome-stable - - name: Remove default Chromium - run: sudo apt purge chromium-browser - - name: Install a new Chromium - run: sudo apt install -y chromium-browser + - uses: browser-actions/setup-chrome@latest + - run: chrome --version - name: Integration browser test with Pytest run: python -m pytest tests/selenium_tests.py From 250841173828869d77d7101fe813f643fb91c6d3 Mon Sep 17 00:00:00 2001 From: Alvaro Laserna Date: Thu, 7 Dec 2023 14:30:21 +0200 Subject: [PATCH 3/3] add logs in pipeline for pytest --- .github/workflows/integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 0a2845d..98ac3d2 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -30,4 +30,4 @@ jobs: - uses: browser-actions/setup-chrome@latest - run: chrome --version - name: Integration browser test with Pytest - run: python -m pytest tests/selenium_tests.py + run: python -m pytest tests/selenium_tests.py -s