The simplest way to select elements is using natural language with the click() method:
Copy
Ask AI
from askui import Agent, locators as locwith VisionAgent() as agent: agent.tools.webbrowser.open_new("https://docs.askui.com") agent.wait(3) # Wait for page to load # Click using natural language agent.click("Login button")
from askui import Agent, locators as locwith VisionAgent() as agent: agent.tools.webbrowser.open_new("https://docs.askui.com") agent.wait(3) # Wait for page to load agent.click(loc.Element("textfield")) agent.type("Hello")
Find elements based on their position relative to other elements:
Copy
Ask AI
# Click the textfield to the right of "Username"agent.click( loc.Element().right_of(loc.Text("Username")))# Select button below specific textagent.click( loc.Element().below_of(loc.Text("Terms and Conditions")))# Find element nearest to anotheragent.click( loc.Text("Edit").nearest_to(loc.Text("Profile Settings")))
# Select the first matching elementagent.click(loc.Text("Delete").first())# Select by index (0-based)agent.click(loc.Element("button").at_index(2))# Select within a specific areaagent.click( loc.Text("Submit").inside_of(loc.Element("form")))
# Set display before interactions (1-based)agent.tools.os.set_display(2) # Use second displayagent.click("Submit")# Or with locatorsagent.tools.os.set_display(1) # Use primary displayagent.click(loc.Text("Submit"))