Spaces:
Paused
Paused
Update ui/tabs_advanced.py
Browse files- ui/tabs_advanced.py +113 -5
ui/tabs_advanced.py
CHANGED
|
@@ -1,12 +1,16 @@
|
|
| 1 |
"""
|
| 2 |
-
Advanced feature tabs
|
| 3 |
-
Note: The advanced features (HTTP requests, monitoring, accessibility, etc.)
|
| 4 |
-
need to be implemented in separate feature modules first
|
| 5 |
"""
|
| 6 |
import gradio as gr
|
| 7 |
from features.http_requests import make_http_request, export_as_curl, get_request_history
|
| 8 |
from features.advanced import wait_for_element, scroll_page, hover_element, press_key
|
| 9 |
from features.extraction import get_page_info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
def create_advanced_tabs():
|
| 12 |
"""Create tabs for advanced browser features"""
|
|
@@ -115,5 +119,109 @@ def create_advanced_tabs():
|
|
| 115 |
get_page_info, [url_in_info, persist_check_info], out_info
|
| 116 |
)
|
| 117 |
|
| 118 |
-
|
| 119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
"""
|
| 2 |
+
Advanced feature tabs for the UI
|
|
|
|
|
|
|
| 3 |
"""
|
| 4 |
import gradio as gr
|
| 5 |
from features.http_requests import make_http_request, export_as_curl, get_request_history
|
| 6 |
from features.advanced import wait_for_element, scroll_page, hover_element, press_key
|
| 7 |
from features.extraction import get_page_info
|
| 8 |
+
from features.monitoring import monitor_network_requests, get_console_logs
|
| 9 |
+
from features.accessibility import accessibility_audit, check_color_contrast
|
| 10 |
+
from features.analysis import (
|
| 11 |
+
extract_structured_data, visual_regression_test,
|
| 12 |
+
extract_all_links, seo_analysis
|
| 13 |
+
)
|
| 14 |
|
| 15 |
def create_advanced_tabs():
|
| 16 |
"""Create tabs for advanced browser features"""
|
|
|
|
| 119 |
get_page_info, [url_in_info, persist_check_info], out_info
|
| 120 |
)
|
| 121 |
|
| 122 |
+
with gr.Tab("π Network Monitor"):
|
| 123 |
+
with gr.Row():
|
| 124 |
+
url_in_network = gr.Textbox(label="URL", value="https://example.com")
|
| 125 |
+
duration_in = gr.Slider(minimum=1, maximum=30, value=5, label="Monitor Duration (seconds)")
|
| 126 |
+
persist_check_network = gr.Checkbox(label="Use Persistent Browser", value=False)
|
| 127 |
+
out_network = gr.Code(label="Network Requests", language="json", lines=15)
|
| 128 |
+
gr.Button("Monitor Network", variant="primary").click(
|
| 129 |
+
monitor_network_requests,
|
| 130 |
+
[url_in_network, duration_in, persist_check_network],
|
| 131 |
+
out_network
|
| 132 |
+
)
|
| 133 |
+
|
| 134 |
+
# Console logs section
|
| 135 |
+
with gr.Row():
|
| 136 |
+
out_console = gr.Code(label="Console Logs", language="json", lines=10)
|
| 137 |
+
gr.Button("Get Console Logs", variant="secondary").click(
|
| 138 |
+
get_console_logs,
|
| 139 |
+
[url_in_network, persist_check_network],
|
| 140 |
+
out_console
|
| 141 |
+
)
|
| 142 |
+
|
| 143 |
+
with gr.Tab("π Structured Data"):
|
| 144 |
+
with gr.Row():
|
| 145 |
+
url_in_structured = gr.Textbox(label="URL", value="https://example.com")
|
| 146 |
+
persist_check_structured = gr.Checkbox(label="Use Persistent Browser", value=False)
|
| 147 |
+
out_structured = gr.Code(
|
| 148 |
+
label="Structured Data (JSON-LD, Meta, OpenGraph)",
|
| 149 |
+
language="json",
|
| 150 |
+
lines=15
|
| 151 |
+
)
|
| 152 |
+
gr.Button("Extract Structured Data", variant="primary").click(
|
| 153 |
+
extract_structured_data,
|
| 154 |
+
[url_in_structured, persist_check_structured],
|
| 155 |
+
out_structured
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
with gr.Tab("π¨ Visual Testing"):
|
| 159 |
+
with gr.Row():
|
| 160 |
+
url1_in = gr.Textbox(label="URL 1", value="https://example.com")
|
| 161 |
+
url2_in = gr.Textbox(label="URL 2", value="https://example.com/new")
|
| 162 |
+
threshold_in = gr.Slider(minimum=0, maximum=1, value=0.98, label="Similarity Threshold")
|
| 163 |
+
out_visual = gr.Code(label="Visual Comparison Result", language="json", lines=10)
|
| 164 |
+
gr.Button("Compare Pages", variant="primary").click(
|
| 165 |
+
visual_regression_test,
|
| 166 |
+
[url1_in, url2_in, threshold_in],
|
| 167 |
+
out_visual
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
with gr.Tab("βΏ Accessibility"):
|
| 171 |
+
with gr.Row():
|
| 172 |
+
url_in_a11y = gr.Textbox(label="URL", value="https://example.com")
|
| 173 |
+
persist_check_a11y = gr.Checkbox(label="Use Persistent Browser", value=False)
|
| 174 |
+
|
| 175 |
+
with gr.Row():
|
| 176 |
+
with gr.Column():
|
| 177 |
+
out_a11y = gr.Code(label="Accessibility Audit Results", language="json", lines=20)
|
| 178 |
+
gr.Button("Run Full Audit", variant="primary").click(
|
| 179 |
+
accessibility_audit,
|
| 180 |
+
[url_in_a11y, persist_check_a11y],
|
| 181 |
+
out_a11y
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
with gr.Column():
|
| 185 |
+
out_contrast = gr.Code(label="Color Contrast Issues", language="json", lines=20)
|
| 186 |
+
gr.Button("Check Color Contrast", variant="secondary").click(
|
| 187 |
+
check_color_contrast,
|
| 188 |
+
[url_in_a11y, persist_check_a11y],
|
| 189 |
+
out_contrast
|
| 190 |
+
)
|
| 191 |
+
|
| 192 |
+
with gr.Tab("π Link Extractor"):
|
| 193 |
+
with gr.Row():
|
| 194 |
+
url_in_links = gr.Textbox(label="URL", value="https://example.com")
|
| 195 |
+
include_external_check = gr.Checkbox(label="Include External Links", value=True)
|
| 196 |
+
persist_check_links = gr.Checkbox(label="Use Persistent Browser", value=False)
|
| 197 |
+
out_links = gr.Code(label="All Links (Categorized)", language="json", lines=20)
|
| 198 |
+
gr.Button("Extract Links", variant="primary").click(
|
| 199 |
+
extract_all_links,
|
| 200 |
+
[url_in_links, include_external_check, persist_check_links],
|
| 201 |
+
out_links
|
| 202 |
+
)
|
| 203 |
+
|
| 204 |
+
with gr.Tab("π SEO Analysis"):
|
| 205 |
+
with gr.Row():
|
| 206 |
+
url_in_seo = gr.Textbox(label="URL", value="https://example.com")
|
| 207 |
+
persist_check_seo = gr.Checkbox(label="Use Persistent Browser", value=False)
|
| 208 |
+
out_seo = gr.Code(label="SEO Analysis Results", language="json", lines=20)
|
| 209 |
+
gr.Button("Analyze SEO", variant="primary").click(
|
| 210 |
+
seo_analysis,
|
| 211 |
+
[url_in_seo, persist_check_seo],
|
| 212 |
+
out_seo
|
| 213 |
+
)
|
| 214 |
+
|
| 215 |
+
gr.Markdown("""
|
| 216 |
+
### π Advanced Features Guide:
|
| 217 |
+
|
| 218 |
+
**π Network Monitor**: Captures XHR, fetch requests, and resource loading
|
| 219 |
+
**π Structured Data**: Extracts JSON-LD, OpenGraph, Twitter Cards, microdata
|
| 220 |
+
**βΏ Accessibility**: WCAG compliance checking with detailed recommendations
|
| 221 |
+
**π¨ Visual Testing**: Compare two pages for visual differences
|
| 222 |
+
**π Link Extractor**: Categorizes all links (internal, external, downloads, etc.)
|
| 223 |
+
**π SEO Analysis**: Comprehensive SEO audit with scoring and recommendations
|
| 224 |
+
**π Console Logs**: Capture browser console output for debugging
|
| 225 |
+
|
| 226 |
+
All features support persistent browser sessions for faster sequential operations!
|
| 227 |
+
""")
|