-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathandroidWeb.py
More file actions
63 lines (54 loc) · 2.03 KB
/
androidWeb.py
File metadata and controls
63 lines (54 loc) · 2.03 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
from appium import webdriver
from appium.options.android import UiAutomator2Options
import time
import os
desired_caps = {
"deviceName": "Galaxy .*",
"platformName": "Android",
"platformVersion": "14",
"isRealMobile": True,
"build": "Python Vanilla Android",
"name": "Sample Test - Python",
"network": False,
"visual": True,
"video": True
}
def startingTest():
if os.environ.get("LT_USERNAME") is None:
# Enter LT username here if environment variables have not been added
username = "username"
else:
username = os.environ.get("LT_USERNAME")
if os.environ.get("LT_ACCESS_KEY") is None:
# Enter LT accesskey here if environment variables have not been added
accesskey = "accesskey"
else:
accesskey = os.environ.get("LT_ACCESS_KEY")
try:
options = UiAutomator2Options()
for key, value in desired_caps.items():
options.set_capability(key, value)
driver = webdriver.Remote(
command_executor="https://" + username + ":" + accesskey + "@mobile-hub.lambdatest.com/wd/hub",
options=options
)
driver.get("https://mfml.in/api/getInfo")
time.sleep(3)
print("Available contexts:", driver.contexts)
try:
driver.execute_script('document.getElementById("resolution").click();')
print("Clicked 'resolution' using JS.")
driver.execute_script('document.getElementById("location").click();')
print("Clicked 'location' using JS.")
driver.execute_script('document.getElementById("details").click();')
print("Clicked 'details' using JS.")
driver.execute_script('document.getElementById("timezone").click();')
print("Clicked 'timezone' using JS.")
except Exception as js_e:
print(f"JS click failed: {js_e}")
driver.quit()
except Exception as e:
print(f"Test failed: {e}")
driver.quit()
if __name__ == "__main__":
startingTest()