-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIOSWeb.python
More file actions
76 lines (62 loc) · 2.43 KB
/
Copy pathIOSWeb.python
File metadata and controls
76 lines (62 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
73
74
75
76
import os
from appium import webdriver
from appium.options.ios import XCUITestOptions
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
PCLOUDY_USERNAME = os.getenv("PCLOUDY_USERNAME", "sample_username")
PCLOUDY_APIKEY = os.getenv("PCLOUDY_APIKEY", "sample_api_key")
def build_options():
pcloudy_options = {
"pCloudy_Username": PCLOUDY_USERNAME,
"pCloudy_ApiKey": PCLOUDY_APIKEY,
"pCloudy_DeviceFullName": "APPLE_iPhone12ProMax_iOS_16.3.1_22ba7",
"pCloudy_WildNet": False,
"pCloudy_EnableVideo": True,
"pCloudy_EnablePerformanceData": False,
"pCloudy_EnableDeviceLogs": False,
"appiumVersion": "3.1.1",
}
opts = XCUITestOptions()
opts.platform_name = "iOS"
opts.platform_version = "15.0.0"
opts.automation_name = "XCUITest"
opts.browser_name = "Safari"
opts.set_capability("safariIgnoreFraudWarning", True)
opts.set_capability("pcloudy:options", pcloudy_options)
return opts
def capture_screenshot(driver, label: str):
os.makedirs("screenshots", exist_ok=True)
path = os.path.join("screenshots", f"iosweb_{label}.png")
driver.save_screenshot(path)
print(f"Saved screenshot: {path}")
def main():
driver = webdriver.Remote(
command_executor="https://device.pcloudy.com/appiumcloud/wd/hub",
options=build_options(),
)
try:
driver.get("https://www.example.com")
WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.TAG_NAME, "body"))
)
print("Opened example.com successfully.")
capture_screenshot(driver, "example_home")
driver.get("https://www.wikipedia.org")
WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "input[name='search']"))
)
print("Opened Wikipedia successfully.")
capture_screenshot(driver, "wikipedia_home")
search_box = driver.find_element(By.CSS_SELECTOR, "input[name='search']")
search_box.send_keys("Appium")
search_box.submit()
WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.ID, "firstHeading"))
)
print("Wikipedia search completed.")
capture_screenshot(driver, "wikipedia_search")
finally:
driver.quit()
if __name__ == "__main__":
main()