-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwake_up.py
More file actions
58 lines (48 loc) · 1.7 KB
/
wake_up.py
File metadata and controls
58 lines (48 loc) · 1.7 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
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
import time
# --- CONFIG ---
URL = "https://pythonforanalytics.streamlit.app/"
WAKEUP_BUTTONS = [
'button[data-testid="wakeup-button-owner"]',
'button[data-testid="wakeup-button-viewer"]'
]
# --- SETUP CHROME DRIVER ---
options = Options()
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-dev-shm-usage")
options.add_argument("--window-size=1920,1080")
driver = webdriver.Chrome(options=options)
try:
driver.get(URL)
time.sleep(5)
# --- CHECK FOR WAKEUP BUTTON ---
wake_button = None
for selector in WAKEUP_BUTTONS:
try:
wake_button = driver.find_element(By.CSS_SELECTOR, selector)
break
except:
continue
if wake_button:
driver.execute_script("arguments[0].click();", wake_button)
print("✅ App was asleep. Wake-up button clicked.")
# Wait for app to reload
print("⏳ Waiting for app to reload...")
time.sleep(15)
# Confirm reload by checking page content
page_source = driver.page_source
if "streamlit" in page_source.lower() or "data-testid" in page_source.lower():
print("✅ Reload success. App content is visible.")
else:
print("❌ Reload failed. App content not detected.")
else:
print("✅ App is already awake. Performing light interaction.")
driver.execute_script("window.scrollTo(0, document.body.scrollHeight/4);")
time.sleep(2)
except Exception as e:
print("❌ Something went wrong:", e)
finally:
driver.quit()