Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I can think of two ways of doing this.</p> <p>One - for each web element you can check its size, location, visibility, etc. After each resize you could compare those parameters with some previously specified values to check if layout has changed.</p> <p>Second - image comparison. After each resize you could take a screenshot of the page and compare it to previously saved pattern. There are various image comparison libraries to achieve that. In our company we use <a href="http://www.imagemagick.org/" rel="noreferrer">ImageMagick</a>. The image comparison however is not suitable for pages under development nor for the ones with changing content. You may get around this problem by hiding the parts of page that are prone to changes with javascript (this is doable with WebDriver).</p> <p>I must admit I never had opportunity to test responsive pages neither manually nor automatically, so the above are just my ideas. I do use image comparison for testing "normal" pages, I am not sure if it will be suitable for responsive pages too.</p> <p><strong>EDIT</strong></p> <p>Unfortunately I don't know Ruby. Below is an example in Java I hope you can understand it and translate to Ruby somehow. The code simply prints the size and location of every element from the list.</p> <pre><code>org.openqa.selenium.Point point; org.openqa.selenium.Dimension dimension; List&lt;WebElement&gt; elementsList = driver.findElements(By.xpath("//some/xpath")); for (WebElement element : elementsList) { point = element.getLocation(); dimension = element.getSize(); System.out.println("Element name: " + element.getTagName()); System.out.println("Element size: " + dimension.height + "x" + dimension.width); System.out.println("Element location: " + point.x + ":" + point.y); } </code></pre> <p>Note that every invocation of getLocation() and getSize() causes js to be executed (in order to obtain the values) and it costs time. That's why you should make just one call per element, don't use something like element.getSize().height + "x" + element.getSize().width - it would take twice as much time comparing to the example above.</p> <p>In Ruby the above-mentioned methods are called element.location and element.size</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload