from askui import VisionAgent, ResponseSchemaBasefrom typing import Listclass Tab(ResponseSchemaBase): name: List[str] active: boolclass TabBar(ResponseSchemaBase): tabs: List[Tab]with VisionAgent() as agent: agent.tools.webbrowser.open_new("http://docs.askui.com") agent.wait(3) # Wait for page to load result = agent.get("Can you extract me the tabs?", response_schema=TabBar) print(result.model_dump_json(indent=2))
Handle Dynamic Tabs: Some applications add/remove tabs dynamically
Copy
Ask AI
initial_tabs = agent.get("How many tabs are there?", response_schema=int)# After some actionagent.click("Add new tab")new_tab_count = agent.get("How many tabs are there?", response_schema=int)assert new_tab_count == initial_tabs + 1
Tab Loading States: Wait for tab content to load
Copy
Ask AI
agent.click("Click on Data tab")# Wait for contentcontent_loaded = Falsefor _ in range(10): # Timeout after 10 attempts content_loaded = agent.get( "Is the tab content fully loaded?", response_schema=bool ) if content_loaded: break agent.wait(1)
Keyboard Navigation: Some tab interfaces support keyboard navigation
Copy
Ask AI
# Use keyboard shortcuts for tab navigationagent.key("Ctrl+Tab") # Next tabagent.key("Ctrl+Shift+Tab") # Previous tab