tried using playwright connected headless browser(chrome)
code used:
async def take_screenshots():
async with async_playwright() as p:
browser = await p.chromium.launch(headless=True, args=\["--no-sandbox", "--disable-dev-shm-usage", "--disable-gpu"\])
page = await browser.new_page()
print(“opening app…”)
await page.goto(APP_URL,timeout = 60000)
#
Wait for STABLE page indicator
#await page.get_by_text(“Grocery Revenue Report”).wait_for(timeout=120000)
for director in directors:
try:
print(f"Processing: {director}")
# Click dropdown and select director
dropdowns = page.locator("div\[data-baseweb='select'\]")
director_dropdown = dropdowns.nth(3)
await director_dropdown.wait_for(state=“visible”, timeout=60000)
await director_dropdown.click()
# Select director
option = page.get_by_text(director, exact=True)
await option.wait_for(state=“visible”, timeout=60000)
await option.click()
# Wait for Streamlit to rerender
await page.wait_for_timeout(5000)
#await page.click(f"text=‘{director}’")
# Wait for Streamlit rerun
#await page.wait_for_timeout(3000)
safe_name = clean_name(director)
file_path = os.path.join(OUTPUT_DIR, f"Director {safe_name}.png")
await page.screenshot(path=file_path, full_page=True)
print(f"Saved: {file_path}“)
except Exception as e:
print(f"Error for {director}: {e}”)
await browser.close()
ERR{Error for Director1: Locator.wait_for: Timeout 60000ms exceeded.
Call log:
- waiting for locator(“div[data-baseweb=‘select’]”).nth(3) to be visible}