forked from LambdaTest/LT-appium-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathandroidWeb.py
More file actions
71 lines (56 loc) · 2.18 KB
/
androidWeb.py
File metadata and controls
71 lines (56 loc) · 2.18 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
from appium import webdriver
# For Web tests, we use the standard Selenium 'By'
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
username = "LT_Username"
accesskey = "LT_ACCESS_KEY"
# 1. Modern W3C Capabilities for Mobile Web
options = AppiumOptions()
options.platform_name = "Android"
lt_options = {
"w3c": True,
"deviceName": "Galaxy .*",
"platformVersion": "11",
"isRealMobile": True,
"browserName": "Chrome",
"build": "Python Vanilla Android Web",
"name": "Sample Web 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("Initializing Android Web 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)
# 2. Fixed Element Locators (using standard By.ID)
print("Interacting with page elements...")
colorElement = wait.until(EC.element_to_be_clickable((By.ID, "resolution")))
colorElement.click()
textElement = wait.until(EC.element_to_be_clickable((By.ID, "location")))
textElement.click()
toastElement = wait.until(EC.element_to_be_clickable((By.ID, "details")))
toastElement.click()
notification = wait.until(EC.element_to_be_clickable((By.ID, "timezone")))
notification.click()
time.sleep(5)
print("Web test completed successfully!")
except Exception as e:
print(f"Test failed with error: {e}")
finally:
if driver:
print("Closing session...")
driver.quit()
if __name__ == "__main__":
startingTest()