Single out elements by describing their surroundings
AgentQL allows you to pinpoint specific elements on a website by describing their context. You can do this by using descriptions in parentheses. This is a powerful tool to single out elements on a webpage when there are multiple elements with similar content or attributes.
Overview
This section shows different techniques you can use to help identify specific elements on a webpage.
Using their position on the page
Use the element's position to describe its context effectively. For example, specify that an element appears in a particular section of the page or in relation to nearby elements.
Using element's content or attributes
Describe elements based on their content or attributes. For example, if you are trying to single out the buy button for Macbook Air product in a page with multiple buy buttons, you can describe it as the button that's associated with the Macbook Air product.
Best practices for singling out elements
- Be specific and unambiguous in your descriptions
- Use multiple context clues when necessary
- Ensure uniqueness of described context
Conclusion
When there are many similar items on the page and you want just one, you can use the element's position, contents, and/or attributes ti distinguish it from the surrounding content.