-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_checkbox.py
More file actions
118 lines (92 loc) · 4.54 KB
/
test_checkbox.py
File metadata and controls
118 lines (92 loc) · 4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
"""Test checkbox selection features in SkyDeck dashboard."""
import asyncio
from playwright.async_api import async_playwright
async def test_checkbox_features():
"""Test checkbox selection features."""
async with async_playwright() as p:
# Launch browser
browser = await p.chromium.launch(headless=False)
page = await browser.new_page()
# Navigate to dashboard
await page.goto("http://localhost:8000")
# Wait for page to load
await page.wait_for_selector("#experiments-table")
print("✓ Dashboard loaded")
# Test 1: Check if checkboxes exist
checkboxes = await page.query_selector_all("input[type='checkbox'].row-checkbox")
print(f"✓ Found {len(checkboxes)} experiment checkboxes")
# Test 2: Find select-all checkbox
select_all = await page.query_selector("#select-all")
if select_all:
print("✓ Found select-all checkbox")
else:
print("✗ Select-all checkbox NOT FOUND")
# Test 3: Click individual checkboxes
if len(checkboxes) > 0:
print("\nTesting individual checkbox selection...")
checkbox = checkboxes[0]
await checkbox.click()
await asyncio.sleep(0.5)
is_checked = await checkbox.is_checked()
print(f" First checkbox checked: {is_checked}")
# Check if bulk actions appear
bulk_actions = await page.query_selector("#bulk-actions")
if bulk_actions:
is_visible = await bulk_actions.is_visible()
print(f" Bulk actions visible: {is_visible}")
# Uncheck
await checkbox.click()
await asyncio.sleep(0.5)
print(" Unchecked first checkbox")
# Test 4: Test select-all
if select_all:
print("\nTesting select-all checkbox...")
# Re-query the checkbox to avoid stale reference
select_all_btn = await page.query_selector("#select-all")
await select_all_btn.click()
await asyncio.sleep(0.5)
# Re-query checkboxes after select-all to avoid stale references
checkboxes_after_select = await page.query_selector_all("input[type='checkbox'].row-checkbox")
checked_count = 0
for cb in checkboxes_after_select:
if await cb.is_checked():
checked_count += 1
print(f" Checked count after select-all: {checked_count}/{len(checkboxes_after_select)}")
# Test unselect-all - re-query again
select_all_btn = await page.query_selector("#select-all")
await select_all_btn.click()
await asyncio.sleep(0.5)
# Re-query checkboxes after unselect-all
checkboxes_after_unselect = await page.query_selector_all("input[type='checkbox'].row-checkbox")
checked_count = 0
for cb in checkboxes_after_unselect:
if await cb.is_checked():
checked_count += 1
print(f" Checked count after unselect-all: {checked_count}/{len(checkboxes_after_unselect)}")
# Test 5: Check bulk action buttons
print("\nTesting bulk action buttons...")
# Re-query checkboxes for bulk actions test
checkboxes_for_bulk = await page.query_selector_all("input[type='checkbox'].row-checkbox")
if len(checkboxes_for_bulk) > 0:
# Select one checkbox
await checkboxes_for_bulk[0].click()
await asyncio.sleep(0.5)
# Check which bulk action buttons exist
buttons = {
"Start Selected": await page.query_selector("button:has-text('Start Selected')"),
"Stop Selected": await page.query_selector("button:has-text('Stop Selected')"),
"Duplicate Selected": await page.query_selector("button:has-text('Duplicate Selected')"),
"Delete Selected": await page.query_selector("button:has-text('Delete Selected')"),
}
for name, button in buttons.items():
if button:
is_visible = await button.is_visible()
print(f" {name}: {'visible' if is_visible else 'hidden'}")
else:
print(f" {name}: NOT FOUND")
print("\n=== Test Complete ===")
print("Keeping browser open for 10 seconds for manual inspection...")
await asyncio.sleep(10)
await browser.close()
if __name__ == "__main__":
asyncio.run(test_checkbox_features())