Skip to content

Instantly share code, notes, and snippets.

@gempir
Created November 18, 2025 07:40
Show Gist options
  • Select an option

  • Save gempir/402cd015b719b7c8518944868e83d461 to your computer and use it in GitHub Desktop.

Select an option

Save gempir/402cd015b719b7c8518944868e83d461 to your computer and use it in GitHub Desktop.
Debugging Superset
python3 << 'EOF'
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
print('1. Creating Firefox options...')
opts = Options()
opts.add_argument('--headless')
print('2. Starting Firefox (this might take a moment)...')
start = time.time()
driver = webdriver.Firefox(options=opts)
print(f' Firefox started in {time.time() - start:.1f}s')
print('3. Setting window size...')
driver.set_window_size(1600, 2000)
print('4. Loading Superset homepage...')
start = time.time()
driver.get('http://127.0.0.1:8088')
print(f' Homepage loaded in {time.time() - start:.1f}s')
print(f' Page title: {driver.title}')
print('5. Adding authentication cookie...')
driver.add_cookie({
'name': 'session',
'value': 'YOUR_SESSION_COOKIE_HERE',
'domain': '127.0.0.1'
})
print(' Cookie added')
print('6. Loading dashboard...')
dashboard_url = 'http://127.0.0.1:8088/superset/dashboard/83bea5c4-cc70-44c8-be4d-f8b3ca474956/?force=true&standalone=3'
start = time.time()
driver.get(dashboard_url)
print(f' Dashboard loaded in {time.time() - start:.1f}s')
print(f' Dashboard title: {driver.title}')
print('7. Waiting for dashboard elements (mimics Superset logic)...')
element_name = "dashboard"
try:
# Step 1: Wait for main dashboard element
print(f' 7a. Looking for element with class: {element_name}')
element = WebDriverWait(driver, 60).until(
EC.presence_of_element_located((By.CLASS_NAME, element_name))
)
print(f' Found {element_name}!')
# Step 2: Wait for chart containers
print(' 7b. Waiting for chart-container elements...')
WebDriverWait(driver, 60).until(
EC.visibility_of_all_elements_located((By.CLASS_NAME, "chart-container"))
)
print(' Chart containers visible!')
# Step 2b: Check what's loading
print(' 7b2. Checking what is loading...')
loading_els = driver.find_elements(By.CLASS_NAME, "loading")
print(f' Found {len(loading_els)} loading elements')
# Try to find chart info for stuck loading elements
chart_containers = driver.find_elements(By.CLASS_NAME, "chart-container")
print(f' Found {len(chart_containers)} chart containers total')
stuck_charts = 0
for container in chart_containers:
try:
# Check if this container has a loading spinner
container_loading = container.find_elements(By.CLASS_NAME, "loading")
if container_loading:
stuck_charts += 1
# Try to get chart name/title
try:
header = container.find_element(By.CLASS_NAME, "header-title")
chart_name = header.text
print(f' Stuck chart {stuck_charts}: "{chart_name}"')
except:
print(f' Stuck chart {stuck_charts}: (no title found)')
except:
pass
print(f' Total stuck charts: {stuck_charts}')
# Step 2c: Check browser console for errors
print(' 7b3. Checking browser console for errors...')
# Get browser logs (only works in Chrome, Firefox doesn't support this well)
# Instead, check if there are error elements on the page
try:
error_elements = driver.find_elements(By.XPATH, "//*[contains(@class, 'error') or contains(@class, 'alert')]")
if error_elements:
print(f' Found {len(error_elements)} error/alert elements')
for i, err_el in enumerate(error_elements[:3]):
try:
print(f' Error {i+1}: {err_el.text[:100]}')
except:
pass
else:
print(' No error elements found')
except:
print(' Could not check for errors')
# Check network activity by looking at page source for failed requests
print(' 7b4. Checking if API responses are in page...')
page_source = driver.page_source
if 'chartId' in page_source:
print(' Found chartId in page source - API structure exists')
if 'error' in page_source.lower():
print(' WARNING: "error" text found in page source')
if 'unauthorized' in page_source.lower():
print(' WARNING: "unauthorized" found - auth might be failing!')
# Step 3: Wait and see if any charts finish loading
print(' 7c. Waiting to see if any charts finish loading...')
print(' (Checking every 10 seconds for 120 seconds)')
for check in range(12):
time.sleep(10)
loading_count = len(driver.find_elements(By.CLASS_NAME, "loading"))
print(f' After {(check+1)*10}s: {loading_count} loading elements remaining')
if loading_count == 0:
print(' All charts loaded!')
break
else:
print(' Charts still loading after 120s - they appear to be stuck')
# Step 4: Animation wait
print(' 7d. Waiting 2s for animations...')
time.sleep(2)
# Step 5: Screenshot the element
print('8. Taking screenshot of dashboard element...')
img_bytes = element.screenshot_as_png
with open('/tmp/superset-element.png', 'wb') as f:
f.write(img_bytes)
print(f' Element screenshot saved ({len(img_bytes)} bytes)')
except Exception as e:
print(f' ERROR: {e}')
print(' Debugging: Looking for available elements...')
try:
els = driver.find_elements(By.XPATH, "//*[contains(@class, 'dashboard') or contains(@class, 'grid')]")
print(f' Found {len(els)} elements with "dashboard" or "grid" in class:')
for el in els[:5]:
print(f' - {el.get_attribute("class")}')
except Exception as debug_err:
print(f' Could not list elements: {debug_err}')
print('9. Quitting...')
driver.quit()
print('Done!')
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment