askrobots / postblob Public

An experimental web framework where PostgreSQL does everything: routing, HTML, file storage, jobs and sessions.

0 downloads

postblob/take_screenshots.py
Download zip
Clone
Clone with git
git clone https://gitstable.com/git/askrobots/postblob.git
HTTPS
https://gitstable.com/git/askrobots/postblob.git
SSH
ssh://git@gitstable.com:2222/askrobots/postblob.git

Cloning needs no sign-in. Pushing over HTTPS asks for your username and an access token. SSH needs your key under SSH keys.

danq9 docs: Add screenshots to README ae44e69 1 year, 1 month ago History
take_screenshots.py · 3.9 KB · 115 lines
1#!/usr/bin/env python3
2"""
3Take screenshots of PostBlob application for documentation
4"""
5
6from selenium import webdriver
7from selenium.webdriver.common.by import By
8from selenium.webdriver.support.ui import WebDriverWait
9from selenium.webdriver.support import expected_conditions as EC
10from selenium.webdriver.chrome.options import Options
11from selenium.webdriver.chrome.service import Service
12import time
13import os
14
15def setup_driver():
16 """Setup Chrome driver with options"""
17 options = Options()
18 options.add_argument('--headless') # Run in headless mode
19 options.add_argument('--no-sandbox')
20 options.add_argument('--disable-dev-shm-usage')
21 options.add_argument('--window-size=1920,1080')
22
23 # Try to use Chrome/Chromium
24 try:
25 driver = webdriver.Chrome(options=options)
26 except:
27 # Fallback to Safari if Chrome is not available
28 print("Chrome not found, trying Safari...")
29 driver = webdriver.Safari()
30 driver.set_window_size(1920, 1080)
31
32 return driver
33
34def take_screenshots():
35 """Take screenshots of PostBlob pages"""
36 driver = setup_driver()
37
38 try:
39 print("📸 Taking screenshots of PostBlob...")
40
41 # Create screenshots directory
42 os.makedirs('screenshots', exist_ok=True)
43
44 # 1. Homepage screenshot
45 print("📷 Capturing homepage...")
46 driver.get('http://localhost:8002/')
47 time.sleep(2) # Wait for page to load
48
49 # Scroll to show full page
50 driver.execute_script("window.scrollTo(0, 0);")
51 time.sleep(1)
52 driver.save_screenshot('screenshots/postblob_homepage.png')
53 print("✅ Homepage captured")
54
55 # 2. Natural Language Query in action
56 print("📷 Capturing Natural Language Query...")
57 query_input = driver.find_element(By.ID, 'queryInput')
58 query_input.send_keys('show code')
59
60 # Click the button
61 button = driver.find_element(By.XPATH, '//button[contains(text(), "Ask Database")]')
62 button.click()
63 time.sleep(2) # Wait for response
64
65 driver.save_screenshot('screenshots/postblob_natural_query.png')
66 print("✅ Natural Language Query captured")
67
68 # 3. Code Editor screenshot
69 print("📷 Capturing Code Editor...")
70 driver.get('http://localhost:8002/code')
71 time.sleep(3) # Wait for code editor to load
72
73 # Try to click on a function to show code
74 try:
75 # Click on the first function button
76 function_button = driver.find_element(By.XPATH, '//button[contains(@class, "function-btn")]')
77 function_button.click()
78 time.sleep(2)
79 except:
80 print("Could not click function button")
81
82 driver.save_screenshot('screenshots/postblob_code_editor.png')
83 print("✅ Code Editor captured")
84
85 # 4. API Stats page
86 print("📷 Capturing Stats API response...")
87 driver.get('http://localhost:8002/stats')
88 time.sleep(1)
89 driver.save_screenshot('screenshots/postblob_stats_api.png')
90 print("✅ Stats API captured")
91
92 # 5. Take a screenshot with the API endpoints section visible
93 print("📷 Capturing API endpoints section...")
94 driver.get('http://localhost:8002/')
95 time.sleep(2)
96
97 # Scroll to API endpoints section
98 api_section = driver.find_element(By.XPATH, '//h2[contains(text(), "API Endpoints")]')
99 driver.execute_script("arguments[0].scrollIntoView(true);", api_section)
100 time.sleep(1)
101
102 driver.save_screenshot('screenshots/postblob_api_endpoints.png')
103 print("✅ API endpoints section captured")
104
105 print("\n🎉 All screenshots captured successfully!")
106 print("📁 Screenshots saved in ./screenshots/")
107
108 except Exception as e:
109 print(f"❌ Error taking screenshots: {e}")
110
111 finally:
112 driver.quit()
113
114if __name__ == '__main__':
115 take_screenshots()