Model-config web apps: describe the app in configuration instead of writing code. Built on Polars and DuckDB.
check_customers_page.py · 1.6 KB · 52 lines
| 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | from selenium import webdriver |
| 4 | from selenium.webdriver.common.by import By |
| 5 | from selenium.webdriver.chrome.options import Options |
| 6 | import time |
| 7 | |
| 8 | # Setup Chrome options |
| 9 | options = Options() |
| 10 | options.add_argument('--headless') |
| 11 | options.add_argument('--no-sandbox') |
| 12 | options.add_argument('--disable-dev-shm-usage') |
| 13 | |
| 14 | driver = webdriver.Chrome(options=options) |
| 15 | |
| 16 | try: |
| 17 | # Load the customers page |
| 18 | driver.get("http://localhost:8005/customers") |
| 19 | time.sleep(2) |
| 20 | |
| 21 | # Find all rows in the table |
| 22 | rows = driver.find_elements(By.CSS_SELECTOR, "tbody tr") |
| 23 | print(f"Found {len(rows)} customer rows") |
| 24 | |
| 25 | # Check for Dan in the table |
| 26 | page_source = driver.page_source |
| 27 | if "Dan" in page_source: |
| 28 | print("✓ 'Dan' found on the page") |
| 29 | else: |
| 30 | print("✗ 'Dan' NOT found on the page") |
| 31 | |
| 32 | # Look for pagination controls |
| 33 | pagination = driver.find_elements(By.CSS_SELECTOR, ".pagination, .page, button") |
| 34 | print(f"Found {len(pagination)} pagination-related elements") |
| 35 | |
| 36 | # Print customer names visible on the page |
| 37 | print("\nCustomers visible on page:") |
| 38 | for row in rows: |
| 39 | try: |
| 40 | cells = row.find_elements(By.TAG_NAME, "td") |
| 41 | if len(cells) > 1: |
| 42 | print(f" - {cells[1].text}") # Name is usually in the second column |
| 43 | except: |
| 44 | pass |
| 45 | |
| 46 | # Check if there's a way to show more records |
| 47 | selects = driver.find_elements(By.TAG_NAME, "select") |
| 48 | for select in selects: |
| 49 | print(f"\nFound select element: {select.get_attribute('outerHTML')[:100]}...") |
| 50 | |
| 51 | finally: |
| 52 | driver.quit() |