Locating Elements in TestDriver
Learn how to effectively describe and locate elements using TestDriver’s visual understanding capabilities.
TestDriver uses visual understanding to locate elements on the screen. Unlike traditional testing frameworks that rely on selectors or element IDs, TestDriver identifies elements based on their visual appearance. This guide explains how to describe elements effectively to ensure TestDriver can locate them accurately.
KeypPrinciples for locating elements
-
Describe the Element Visually:
- Focus on the appearance of the element, not its behavior or function.
- Mention unique visual traits such as text, color, size, position, or icon.
-
Avoid Behavioral Descriptions:
- don’t describe what the element does (for example, “button that submits the form”).
- Instead, describe how it looks (for example, “blue button with the text ‘Submit’ in the bottom-right corner”).
-
Use Unique Identifiers:
- If the element has visible text, include it in the description.
- For icons or images, describe their shape, color, or associated label.
-
Leverage Visual Feedback:
- TestDriver will draw yellow boxes around detected elements during test execution.
- Use this feedback to verify that the correct element is being targeted.
Examples of effective descriptions
1. Buttons
- Good: “Blue button with the text ‘Sign In’ in the top-right corner.”
- Bad: “Button that logs the user in.”
2. Links
- Good: “Hyperlink with the text ‘Learn More’ in the footer.”
- Bad: “Link that navigates to the About page.”
3. Icons
- Good: “Magnifying glass icon next to the search bar.”
- Bad: “Search icon that opens the search feature.”
4. Input fields
- Good: “White input box labeled ‘Email Address’ above the password field.”
- Bad: “Field where the user enters their email.”
5. Images
- Good: “Company logo in the top-left corner, a blue circle with white text.”
- Bad: “Logo that redirects to the homepage.”
How to write TestDriver commands
Example: Locating a button
TestDriver command:
Example: Locating an icon
TestDriver command:
Example: Locating a link
TestDriver command:
Debugging element detection
-
Run the Test:
- Execute the test using TestDriver.
- TestDriver will draw yellow boxes around detected elements.
-
Verify the Correct Element:
- Ensure the yellow box highlights the intended element.
- If the wrong element is highlighted, refine your description.
-
Adjust the Description:
- Add more specific visual details (for example, color, position, associated text).
- Avoid generic terms like “button” or “icon” without additional context.
Best practices
-
Be Specific:
- Include as many unique visual traits as possible to differentiate the element from others.
-
Test Incrementally:
- Run tests after adding or modifying commands to verify element detection.
-
Use Visual Feedback:
- Leverage the yellow boxes drawn by TestDriver to confirm the correct element is being targeted.
-
Avoid Overloading Descriptions:
- Keep descriptions concise but detailed enough to uniquely identify the element.
By focusing on visual descriptions and leveraging TestDriver’s feedback, you can accurately locate elements and create robust, reliable tests.