forked from LambdaTest/LT-appium-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiosWeb.py
More file actions
72 lines (59 loc) · 2.43 KB
/
iosWeb.py
File metadata and controls
72 lines (59 loc) · 2.43 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
from appium import webdriver
# FIXED: Using standard Selenium By for Web elements
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from appium.options.common import AppiumOptions
import time
import os
def startingTest():
# Credentials - Using your provided details
username = "LT_Username"
accesskey = "LT_Access_key"
# 1. Setup Modern Appium Options
options = AppiumOptions()
options.platform_name = "ios"
# 2. Define LambdaTest Specific Capabilities (W3C compliant)
lt_options = {
"w3c": True,
"deviceName": "iPhone.*", # Regex to find any available iPhone
"platformVersion": "15", # iOS 15 is highly stable for Safari testing
"isRealMobile": True,
"browserName": "Safari", # Essential for Mobile Web tests
"build": "Python Vanilla iOS Web",
"name": "Sample Web Test - Python",
"network": True,
"visual": True,
"video": True
}
options.set_capability("lt:options", lt_options)
# Connection URL
remote_url = f"https://{username}:{accesskey}@mobile-hub.lambdatest.com/wd/hub"
driver = None
try:
print("Initializing iOS Safari session on LambdaTest...")
driver = webdriver.Remote(command_executor=remote_url, options=options)
print("Opening URL: https://mfml.in/api/getInfo")
driver.get("https://mfml.in/api/getInfo")
wait = WebDriverWait(driver, 30)
# 3. Interacting with Web Elements using standard By.ID
print("Clicking Resolution...")
colorElement = wait.until(EC.element_to_be_clickable((By.ID, "resolution")))
colorElement.click()
print("Clicking Location...")
textElement = wait.until(EC.element_to_be_clickable((By.ID, "location")))
textElement.click()
print("Clicking Details...")
toastElement = wait.until(EC.element_to_be_clickable((By.ID, "details")))
toastElement.click()
print("Clicking Timezone...")
notification = wait.until(EC.element_to_be_clickable((By.ID, "timezone")))
notification.click()
time.sleep(5)
print("Test completed successfully!")
except Exception as e:
print(f"Test failed with error: {e}")
finally:
if driver:
print("Closing session...")
driver