Skip to content

Commit

Permalink
Merge pull request #10 from testdevlab/exclude_driver_test
Browse files Browse the repository at this point in the history
Exclude TestUIDriver from pytest collection
  • Loading branch information
alvarolaserna authored Mar 26, 2021
2 parents 181b783 + d3dbfbd commit 5d392cc
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
23 changes: 23 additions & 0 deletions tests/appium_app_test.py
Original file line number Diff line number Diff line change
@@ -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()
4 changes: 4 additions & 0 deletions tests/screens/landing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ 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):
self.__log_in_button.wait_until_visible()

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()
2 changes: 1 addition & 1 deletion testui/elements/testui_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 2 additions & 0 deletions testui/support/appium_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions testui/support/testui_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5d392cc

Please sign in to comment.