forked from LambdaTest/LT-appium-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathios.py
More file actions
63 lines (50 loc) · 2.13 KB
/
ios.py
File metadata and controls
63 lines (50 loc) · 2.13 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.webdriver.common.appiumby import AppiumBy
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from appium.options.common import AppiumOptions
import time
def startingTest():
username = "LT_username"
accesskey = "LT_access_key"
options = AppiumOptions()
options.platform_name = "ios"
# Using a very stable configuration for Real Devices
lt_options = {
"w3c": True,
"deviceName": "iPhone.*", # This will pick any available iPhone
"platformVersion": "15", # iOS 15 is highly available
"isRealMobile": True,
"app": "lt://APP1016034271771508979736192",
"build": "Python Vanilla iOS",
"name": "Sample Test - Python",
"network": True,
"visual": True,
"video": True
}
options.set_capability("lt:options", lt_options)
remote_url = f"https://{username}:{accesskey}@mobile-hub.lambdatest.com/wd/hub"
driver = None
try:
print(f"Connecting to LambdaTest Hub (using {lt_options['deviceName']})...")
# The script often 'pauses' here while LambdaTest allocates a real device
driver = webdriver.Remote(command_executor=remote_url, options=options)
print("SUCCESS: Session started!")
wait = WebDriverWait(driver, 30) # Increased wait time for cloud latency
# Test Steps
print("Clicking Color...")
wait.until(EC.element_to_be_clickable((AppiumBy.ACCESSIBILITY_ID, "color"))).click()
print("Clicking Text...")
wait.until(EC.element_to_be_clickable((AppiumBy.ACCESSIBILITY_ID, "Text"))).click()
print("Clicking Toast...")
wait.until(EC.element_to_be_clickable((AppiumBy.ACCESSIBILITY_ID, "toast"))).click()
print("Test completed successfully!")
except Exception as e:
print(f"\nERROR: Test failed.")
print(f"Details: {e}")
finally:
if driver:
print("Closing session...")
driver.quit()
if __name__ == "__main__":
startingTest()