Use boolean response schemas to check UI states, verify conditions, and make decisions in your automation flows.
Basic Usage
from askui import VisionAgent
with VisionAgent() as agent:
agent.tools.webbrowser.open_new("http://www.example.com")
agent.wait(3) # Wait for page to load
is_loaded = agent.get("Is the page fully loaded?", response_schema=bool)
assert is_loaded, "Page should be loaded"
print(f"is loaded: {is_loaded}")
Best Practices
-
Be Specific: Ask precise questions about what you’re checking
# Good - specific
is_error = agent.get("Is there a red error message below the email field?", response_schema=bool)
# Less specific
is_error = agent.get("Is there an error?", response_schema=bool)
-
Use for Control Flow: Boolean questions are perfect for conditional logic
if agent.get("Is the cookie banner visible?", response_schema=bool):
agent.click("Accept cookies")
# Continue with main flow
-
Combine Multiple Checks: Use multiple boolean questions for complex validations
can_proceed = all([
agent.get("Is the form completely filled?", response_schema=bool),
agent.get("Is the terms checkbox checked?", response_schema=bool),
not agent.get("Are there any validation errors?", response_schema=bool)
])