|
| 1 | +"""Test script to diagnose the star button issue with Playwright.""" |
| 2 | + |
| 3 | +import asyncio |
| 4 | + |
| 5 | +from playwright.async_api import async_playwright |
| 6 | + |
| 7 | + |
| 8 | +async def main(): |
| 9 | + async with async_playwright() as p: |
| 10 | + browser = await p.chromium.launch(headless=False) |
| 11 | + page = await browser.new_page() |
| 12 | + |
| 13 | + # Navigate to the dashboard |
| 14 | + await page.goto("http://127.0.0.1:8000") |
| 15 | + |
| 16 | + # Wait for experiments to load |
| 17 | + await page.wait_for_selector("tr.main-row", timeout=10000) |
| 18 | + |
| 19 | + # Get the first experiment row |
| 20 | + first_row = await page.query_selector("tr.main-row") |
| 21 | + |
| 22 | + if first_row: |
| 23 | + # Get the data-exp-id attribute |
| 24 | + exp_id = await first_row.get_attribute("data-exp-id") |
| 25 | + print(f"Row data-exp-id: {exp_id}") |
| 26 | + |
| 27 | + # Get the ID cell content |
| 28 | + id_cell = await first_row.query_selector("td.col-id") |
| 29 | + id_text = await id_cell.text_content() |
| 30 | + print(f"ID cell text content: {repr(id_text)}") |
| 31 | + |
| 32 | + # Get the span with the actual ID |
| 33 | + id_span = await id_cell.query_selector("span") |
| 34 | + if id_span: |
| 35 | + span_text = await id_span.text_content() |
| 36 | + print(f"ID span text: {repr(span_text)}") |
| 37 | + |
| 38 | + # Check if there's a checkpoints container in an expanded row |
| 39 | + expanded_row = await page.query_selector(f'tr.expanded-row[data-exp-id="{exp_id}"]') |
| 40 | + if expanded_row: |
| 41 | + print("Expanded row exists") |
| 42 | + checkpoints_div = await expanded_row.query_selector(f"#checkpoints-{exp_id}") |
| 43 | + if checkpoints_div: |
| 44 | + print(f"Found checkpoints container with ID: checkpoints-{exp_id}") |
| 45 | + else: |
| 46 | + print(f"Checkpoints container NOT found with ID: checkpoints-{exp_id}") |
| 47 | + # Try to find what ID it actually has |
| 48 | + all_checkpoint_divs = await expanded_row.query_selector_all("[id^='checkpoints-']") |
| 49 | + for div in all_checkpoint_divs: |
| 50 | + actual_id = await div.get_attribute("id") |
| 51 | + print(f"Found checkpoints container with ID: {actual_id}") |
| 52 | + |
| 53 | + # Click the row to expand it |
| 54 | + print("\nClicking row to expand...") |
| 55 | + await first_row.click() |
| 56 | + await page.wait_for_timeout(1000) # Wait for expansion |
| 57 | + |
| 58 | + # Check the expanded row again |
| 59 | + expanded_row = await page.query_selector(f'tr.expanded-row[data-exp-id="{exp_id}"].show') |
| 60 | + if expanded_row: |
| 61 | + print("Row is now expanded") |
| 62 | + checkpoints_div = await expanded_row.query_selector(f"#checkpoints-{exp_id}") |
| 63 | + if checkpoints_div: |
| 64 | + print(f"Checkpoints container found: checkpoints-{exp_id}") |
| 65 | + else: |
| 66 | + print(f"Checkpoints container STILL not found: checkpoints-{exp_id}") |
| 67 | + # Find all divs with checkpoints prefix |
| 68 | + all_divs_with_id = await expanded_row.query_selector_all("[id]") |
| 69 | + for div in all_divs_with_id: |
| 70 | + actual_id = await div.get_attribute("id") |
| 71 | + if "checkpoints" in actual_id: |
| 72 | + print(f"Found: {actual_id}") |
| 73 | + |
| 74 | + # Keep browser open for inspection |
| 75 | + print("\nBrowser will stay open for 10 seconds...") |
| 76 | + await page.wait_for_timeout(10000) |
| 77 | + await browser.close() |
| 78 | + |
| 79 | + |
| 80 | +if __name__ == "__main__": |
| 81 | + asyncio.run(main()) |
0 commit comments