-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathAndroidStepDef.py
More file actions
83 lines (63 loc) · 2.61 KB
/
AndroidStepDef.py
File metadata and controls
83 lines (63 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from appium.webdriver.common.appiumby import AppiumBy
from appium.options.android import UiAutomator2Options
from appium import webdriver
from behave import given
import appConfig as appConf
import sys
import os
path = os.getcwd()
sys.path.append(os.path.abspath(os.path.join(path, os.pardir)))
@given("Start the android app automation test")
def startAndroidAppAutomationTest(context):
username = os.environ.get("LT_USERNAME") or "username"
accesskey = os.environ.get("LT_ACCESS_KEY") or "accesskey"
caps = appConf.app_android_desired_caps
# Add LambdaTest credentials inside lt:options
if "lt:options" not in caps:
caps["lt:options"] = {}
caps["lt:options"]["user"] = username
caps["lt:options"]["accessKey"] = accesskey
options = UiAutomator2Options().load_capabilities(caps)
driver = webdriver.Remote(
command_executor="https://mobile-hub.lambdatest.com/wd/hub",
options=options
)
try:
colorElement = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/color"))
)
colorElement.click()
textElement = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/Text"))
)
textElement.click()
toastElement = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/toast"))
)
toastElement.click()
notification = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/notification"))
)
notification.click()
geolocation = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/geoLocation"))
)
geolocation.click()
home = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/Home"))
)
home.click()
speedTest = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/speedTest"))
)
speedTest.click()
home = WebDriverWait(driver, 20).until(
EC.element_to_be_clickable((AppiumBy.ID, "com.lambdatest.proverbial:id/Home"))
)
home.click()
driver.quit()
except Exception as e:
print("Test failed:", e)
driver.quit()