Last updated on July 19th, 2025 at 10:59 am
When automating web testing with Selenium IDE, you may sometimes need to capture the position of a web element on the page. This is especially helpful when verifying visual placements or ensuring the UI renders consistently across browsers or screen sizes. Selenium IDE offers two helpful commands for this purpose: storeElementPositionLeft and storeElementPositionTop.
What is storeElementPositionLeft in Selenium?
The storeElementPositionLeft command retrieves the horizontal (left) position of a web element and stores it into a variable. This value can be used later for assertions, debugging layout issues, or verifying element alignment.
Syntax:
storeElementPositionLeft | locator | variableName
Example:
storeElementPositionLeft | name=q | left
In this example, Selenium finds the Google search box using name=q and stores its horizontal position in a variable called left.
What is storeElementPositionTop in Selenium?
The storeElementPositionTop command works similarly, but it stores the vertical (top) position of an element. This is useful for verifying whether an element appears in the correct vertical location on the screen.
Syntax:
storeElementPositionTop | locator | variableName
Example:
storeElementPositionTop | name=q | top
This stores the vertical position of the same search box in the variable top.
When to Use These Commands
- To verify the alignment of elements (e.g., button or banner positions).
- To debug layout shifts or overlapping components during regression testing.
- To ensure consistent rendering across screen resolutions or browser types.
How to Use Stored Position Values in Assertions
You can use the stored values to assert position-related conditions. For instance:
storeElementPositionLeft | name=q | left
echo | ${left}
storeElementPositionTop | name=q | top
assert | ${top} | 100
This checks if the top position of the element equals 100 pixels.
Conclusion
The storeElementPositionLeft and storeElementPositionTop commands are valuable tools in Selenium IDE when you want to validate the layout of elements on your web application. Use them for pixel-perfect UI testing or to catch hidden alignment bugs early.
Want to learn more about Selenium IDE commands? Check out our full guide: Selenium IDE Tutorial.
FAQs
What does storeElementPositionLeft do in Selenium?
It stores the horizontal (left) position of a specified web element into a variable for later use or validation in Selenium IDE.
How is storeElementPositionTop different from storeElementPositionLeft?
storeElementPositionTop stores the vertical (top) position of an element, while storeElementPositionLeft stores the horizontal (left) position.
Can I use these position values in assertions?
Yes, the stored values can be used in assert or verify commands to validate element positioning during tests.

Hi, I’m Aravind — a seasoned Automation Test Engineer with over 17 years of hands-on experience in the software testing industry. I specialize in tech troubleshooting and tools like Selenium, Playwright, Appium, JMeter, and Excel automation. Through this blog, I share practical tutorials, expert tips, and real-world insights to help testers and developers improve their automation skills.In addition to software testing, I also explore tech trends and user-focused topics, including Snapchat guides, codeless test automation, and more.