diff --git a/tests/appium_app_test.py b/tests/appium_app_test.py new file mode 100644 index 0000000..e75b132 --- /dev/null +++ b/tests/appium_app_test.py @@ -0,0 +1,23 @@ +import pytest + +from tests.screens.landing import LandingScreen +from testui.support import logger +from testui.support.appium_driver import NewDriver +from testui.support.testui_driver import TestUIDriver + + +class TestStringMethods(object): + @pytest.yield_fixture(autouse=True) + def appium_driver(self): + driver = NewDriver() \ + .set_app_package_activity("com.android.vending", ".AssetBrowserActivity") \ + .set_logger().set_soft_assert(True).set_appium_driver() + yield driver + driver.quit() + + @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() + appium_driver.raise_errors() diff --git a/tests/screens/landing.py b/tests/screens/landing.py index 3df3997..46c4bb4 100644 --- a/tests/screens/landing.py +++ b/tests/screens/landing.py @@ -6,6 +6,7 @@ class LandingScreen(object): def __init__(self, driver): self.__log_in_button = e(driver, "name", "btnK") self.__log_in_button_2 = e(driver, "xpath", "//button[@class='Tg7LZd']") + self.__google_play_screen = e(driver, "uiautomator", "text(\"Apps\")") # Page Methods def i_am_in_landing_screen(self): @@ -13,3 +14,6 @@ def i_am_in_landing_screen(self): def i_am_in_mobile_landing_screen(self): self.__log_in_button_2.wait_until_visible() + + def i_am_in_google_play_landing_screen(self): + self.__google_play_screen.wait_until_visible().get_text() diff --git a/testui/elements/testui_element.py b/testui/elements/testui_element.py index 156e8f0..627c6b1 100644 --- a/testui/elements/testui_element.py +++ b/testui/elements/testui_element.py @@ -617,7 +617,7 @@ def get_text(self): err = None while time.time() < start + timeout: try: - text = self.get_element().get_attribute("text") + text = self.get_element().text self.__put_log( f'{self.device_name}: element "{self.locator_type}: {self.locator}" ' f'has text "{text}" {time.time() - start}s' diff --git a/testui/support/appium_driver.py b/testui/support/appium_driver.py index 83e673a..0830cea 100644 --- a/testui/support/appium_driver.py +++ b/testui/support/appium_driver.py @@ -386,6 +386,8 @@ def __set_ios_device(desired_caps, number: int): def get_device_udid(number: int): client = AdbClient(host="127.0.0.1", port=5037) devices = client.devices() + if len(devices) == 0: + raise Exception("There are 0 devices connected to the computer!") if len(devices) > number: return devices[number].get_serial_no() else: diff --git a/testui/support/testui_driver.py b/testui/support/testui_driver.py index b761d4f..0461fce 100644 --- a/testui/support/testui_driver.py +++ b/testui/support/testui_driver.py @@ -15,6 +15,9 @@ from testui.support.configuration import Configuration class TestUIDriver: + __test__ = False + + def __init__(self, driver): self.__soft_assert = driver.soft_assert self.__appium_driver = driver.get_driver()