-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathiosWeb.py
More file actions
77 lines (66 loc) · 2.46 KB
/
iosWeb.py
File metadata and controls
77 lines (66 loc) · 2.46 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
from appium import webdriver
from appium.options.ios import XCUITestOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
import os
desired_caps = {
"deviceName": "iPhone .*",
"platformName": "ios",
"platformVersion": "14",
"isRealMobile": True,
"build": "Python Vanilla iOS",
"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 = XCUITestOptions()
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)
# Wait for and click resolution
resolution = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((By.ID, "resolution")))
resolution.click()
print("Clicked 'resolution' using Selenium.")
# Wait for and click location
location = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((By.ID, "location")))
location.click()
print("Clicked 'location' using Selenium.")
# Wait for and click details
details = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((By.ID, "details")))
details.click()
print("Clicked 'details' using Selenium.")
# Wait for and click timezone
timezone = WebDriverWait(driver, 30).until(
EC.element_to_be_clickable((By.ID, "timezone")))
timezone.click()
print("Clicked 'timezone' using Selenium.")
driver.quit()
except Exception as e:
print(f"Test failed: {e}")
driver.quit()
if __name__ == "__main__":
startingTest()