Testing the Page Layout with Selenium Webdriver

If you are looking to test

  • Overlapping objects with selenium webdriver?
  • page layout of a website?
Easiest way to do that:

webelement.getPosition() and webelement.getDimension().
These two methods are quite good when it comes to testing the layout of a webpage. I did a quick test and found that the location would return the location of the element relative to the left top corner of the page. That means this should always return the same value irrespective of monitor resolution or window size.
If you can record the location and element dimension once and store these values somewhere, You can then run automated tests using selenium to find whether the position or dimension of the element changed. If that change is greater than a delta value, then it means the alignment of the element has changed and the test has Failed!


Popular posts from this blog

XPATH for IE / internet explorer

RPA - Blue Prism, OpenSpan, Automation Anywhere vs UIPath