Update app.py
Browse files
app.py
CHANGED
|
@@ -394,8 +394,16 @@ def run_all_tests(url):
|
|
| 394 |
|
| 395 |
return perf, seo, sec, a11y
|
| 396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 397 |
# Create Gradio Interface
|
| 398 |
-
with gr.Blocks(title="Web Testing Suite", theme=gr.themes.Soft()) as demo:
|
| 399 |
gr.Markdown("""
|
| 400 |
# π Comprehensive Web Testing Suite
|
| 401 |
Test any website for **Performance**, **SEO**, **Security**, and **Accessibility**
|
|
@@ -404,12 +412,73 @@ with gr.Blocks(title="Web Testing Suite", theme=gr.themes.Soft()) as demo:
|
|
| 404 |
with gr.Row():
|
| 405 |
url_input = gr.Textbox(
|
| 406 |
label="π Website URL",
|
| 407 |
-
placeholder="https://example.com",
|
| 408 |
scale=3
|
| 409 |
)
|
| 410 |
|
| 411 |
with gr.Row():
|
| 412 |
test_all_btn = gr.Button("π Run All Tests", variant="primary", scale=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
|
| 414 |
with gr.Row():
|
| 415 |
perf_btn = gr.Button("β‘ Performance", scale=1)
|
|
@@ -419,16 +488,55 @@ with gr.Blocks(title="Web Testing Suite", theme=gr.themes.Soft()) as demo:
|
|
| 419 |
|
| 420 |
with gr.Tabs():
|
| 421 |
with gr.Tab("β‘ Performance"):
|
| 422 |
-
perf_output = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
|
| 424 |
with gr.Tab("π SEO"):
|
| 425 |
-
seo_output = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 426 |
|
| 427 |
with gr.Tab("π Security"):
|
| 428 |
-
sec_output = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
|
| 430 |
with gr.Tab("βΏ Accessibility"):
|
| 431 |
-
a11y_output = gr.Textbox(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 432 |
|
| 433 |
# Button actions
|
| 434 |
test_all_btn.click(
|
|
@@ -441,15 +549,6 @@ with gr.Blocks(title="Web Testing Suite", theme=gr.themes.Soft()) as demo:
|
|
| 441 |
seo_btn.click(run_seo_audit, inputs=[url_input], outputs=[seo_output])
|
| 442 |
sec_btn.click(run_security_test, inputs=[url_input], outputs=[sec_output])
|
| 443 |
a11y_btn.click(run_accessibility_test, inputs=[url_input], outputs=[a11y_output])
|
| 444 |
-
|
| 445 |
-
gr.Markdown("""
|
| 446 |
-
---
|
| 447 |
-
### π What Each Test Checks:
|
| 448 |
-
- **β‘ Performance**: TTFB, Page Size, Resource Count, Compression
|
| 449 |
-
- **π SEO**: Meta Tags, Headers, Sitemap, Title/Description Length
|
| 450 |
-
- **π Security**: SSL, Security Headers, Mixed Content
|
| 451 |
-
- **βΏ Accessibility**: Alt Text, Form Labels, ARIA Roles
|
| 452 |
-
""")
|
| 453 |
|
| 454 |
if __name__ == "__main__":
|
| 455 |
demo.launch()
|
|
|
|
| 394 |
|
| 395 |
return perf, seo, sec, a11y
|
| 396 |
|
| 397 |
+
# Custom CSS for scrollable textboxes
|
| 398 |
+
custom_css = """
|
| 399 |
+
.scrollable-textbox textarea {
|
| 400 |
+
max-height: 400px !important;
|
| 401 |
+
overflow-y: auto !important;
|
| 402 |
+
}
|
| 403 |
+
"""
|
| 404 |
+
|
| 405 |
# Create Gradio Interface
|
| 406 |
+
with gr.Blocks(title="Web Testing Suite", theme=gr.themes.Soft(), css=custom_css) as demo:
|
| 407 |
gr.Markdown("""
|
| 408 |
# π Comprehensive Web Testing Suite
|
| 409 |
Test any website for **Performance**, **SEO**, **Security**, and **Accessibility**
|
|
|
|
| 412 |
with gr.Row():
|
| 413 |
url_input = gr.Textbox(
|
| 414 |
label="π Website URL",
|
| 415 |
+
placeholder="https://example.com or example.com",
|
| 416 |
scale=3
|
| 417 |
)
|
| 418 |
|
| 419 |
with gr.Row():
|
| 420 |
test_all_btn = gr.Button("π Run All Tests", variant="primary", scale=1)
|
| 421 |
+
guideline_btn = gr.Button("π Show Guidelines", variant="secondary", scale=1)
|
| 422 |
+
|
| 423 |
+
# Guidelines Accordion
|
| 424 |
+
with gr.Accordion("π Testing Guidelines & Features", open=False, visible=False) as guidelines_section:
|
| 425 |
+
gr.Markdown("""
|
| 426 |
+
## π¦ What's Included
|
| 427 |
+
|
| 428 |
+
### 1. β‘ Performance Tester
|
| 429 |
+
- **TTFB** (Time To First Byte)
|
| 430 |
+
- Full page load metrics with Selenium
|
| 431 |
+
- DNS, TCP, and response time measurements
|
| 432 |
+
- Payload size analysis (HTML, CSS, JS, images)
|
| 433 |
+
- Resource count tracking
|
| 434 |
+
- Lighthouse integration for Core Web Vitals (FCP, LCP, CLS, TTI)
|
| 435 |
+
|
| 436 |
+
### 2. π SEO Auditor
|
| 437 |
+
- Meta tag validation (title, description, OG tags)
|
| 438 |
+
- Title/description length optimization checks
|
| 439 |
+
- Header structure analysis (H1-H3)
|
| 440 |
+
- Broken internal link detection
|
| 441 |
+
- Sitemap.xml verification
|
| 442 |
+
- JSON-LD schema extraction
|
| 443 |
+
|
| 444 |
+
### 3. π Security Tester
|
| 445 |
+
- SSL certificate validation & expiry check
|
| 446 |
+
- Security headers audit (CSP, HSTS, X-Frame-Options, etc.)
|
| 447 |
+
- Mixed content detection (HTTP on HTTPS pages)
|
| 448 |
+
- Basic XSS vulnerability testing
|
| 449 |
+
- CORS configuration analysis
|
| 450 |
+
|
| 451 |
+
### 4. βΏ Accessibility Tester
|
| 452 |
+
- Missing alt attribute detection
|
| 453 |
+
- ARIA role validation
|
| 454 |
+
- Form label checking
|
| 455 |
+
- Keyboard focus/tabindex analysis
|
| 456 |
+
- WCAG compliance indicators
|
| 457 |
+
|
| 458 |
+
### 5. π€ E2E Tester (Selenium)
|
| 459 |
+
- Login flow automation
|
| 460 |
+
- Form submission testing
|
| 461 |
+
- Button click interactions
|
| 462 |
+
- Screenshot capture
|
| 463 |
+
- Performance tracing
|
| 464 |
+
- Custom test suite runner
|
| 465 |
+
|
| 466 |
+
---
|
| 467 |
+
|
| 468 |
+
## π‘ How to Use
|
| 469 |
+
1. Enter your website URL (with or without https://)
|
| 470 |
+
2. Click **"Run All Tests"** for comprehensive analysis
|
| 471 |
+
3. Or click individual test buttons for specific checks
|
| 472 |
+
4. View detailed results in each tab
|
| 473 |
+
5. Results are scrollable for long outputs
|
| 474 |
+
|
| 475 |
+
## π― Best Practices
|
| 476 |
+
- Test after major updates
|
| 477 |
+
- Regular security audits recommended
|
| 478 |
+
- Fix accessibility issues for better UX
|
| 479 |
+
- Monitor performance metrics monthly
|
| 480 |
+
- Keep SEO elements updated
|
| 481 |
+
""")
|
| 482 |
|
| 483 |
with gr.Row():
|
| 484 |
perf_btn = gr.Button("β‘ Performance", scale=1)
|
|
|
|
| 488 |
|
| 489 |
with gr.Tabs():
|
| 490 |
with gr.Tab("β‘ Performance"):
|
| 491 |
+
perf_output = gr.Textbox(
|
| 492 |
+
label="Performance Test Results",
|
| 493 |
+
lines=20,
|
| 494 |
+
max_lines=20,
|
| 495 |
+
elem_classes=["scrollable-textbox"]
|
| 496 |
+
)
|
| 497 |
|
| 498 |
with gr.Tab("π SEO"):
|
| 499 |
+
seo_output = gr.Textbox(
|
| 500 |
+
label="SEO Audit Results",
|
| 501 |
+
lines=20,
|
| 502 |
+
max_lines=20,
|
| 503 |
+
elem_classes=["scrollable-textbox"]
|
| 504 |
+
)
|
| 505 |
|
| 506 |
with gr.Tab("π Security"):
|
| 507 |
+
sec_output = gr.Textbox(
|
| 508 |
+
label="Security Test Results",
|
| 509 |
+
lines=20,
|
| 510 |
+
max_lines=20,
|
| 511 |
+
elem_classes=["scrollable-textbox"]
|
| 512 |
+
)
|
| 513 |
|
| 514 |
with gr.Tab("βΏ Accessibility"):
|
| 515 |
+
a11y_output = gr.Textbox(
|
| 516 |
+
label="Accessibility Test Results",
|
| 517 |
+
lines=20,
|
| 518 |
+
max_lines=20,
|
| 519 |
+
elem_classes=["scrollable-textbox"]
|
| 520 |
+
)
|
| 521 |
+
|
| 522 |
+
gr.Markdown("""
|
| 523 |
+
---
|
| 524 |
+
### π Quick Reference
|
| 525 |
+
- β
**Green**: Passed / Optimal
|
| 526 |
+
- β οΈ **Yellow**: Needs Attention
|
| 527 |
+
- β **Red**: Failed / Critical Issue
|
| 528 |
+
|
| 529 |
+
*Results are automatically scrollable when content exceeds the display area*
|
| 530 |
+
""")
|
| 531 |
+
|
| 532 |
+
# Toggle guidelines visibility
|
| 533 |
+
def toggle_guidelines():
|
| 534 |
+
return gr.Accordion(visible=True, open=True)
|
| 535 |
+
|
| 536 |
+
guideline_btn.click(
|
| 537 |
+
toggle_guidelines,
|
| 538 |
+
outputs=[guidelines_section]
|
| 539 |
+
)
|
| 540 |
|
| 541 |
# Button actions
|
| 542 |
test_all_btn.click(
|
|
|
|
| 549 |
seo_btn.click(run_seo_audit, inputs=[url_input], outputs=[seo_output])
|
| 550 |
sec_btn.click(run_security_test, inputs=[url_input], outputs=[sec_output])
|
| 551 |
a11y_btn.click(run_accessibility_test, inputs=[url_input], outputs=[a11y_output])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 552 |
|
| 553 |
if __name__ == "__main__":
|
| 554 |
demo.launch()
|