title: Verification of Element in Viewport in Selenium
body: <p>How to verify whether an element is visible in viewport(visibility of browser) or not using Selenium?</p>
  
  <p>I've tried with the below code, but Point object(Y value) returns huge value as page is scrollable. Here am getting element dimensions, location and Dimensions of Browser and comparing them.</p>
  
  <pre><code>Dimension weD = element.getSize(); //to get the element Dimensions
  Point weP = element.getLocation(); // getting the location of the element in the page.
  
  Dimension d = driver.manage().window().getSize(); // To get the browser dimensions
  int x = d.getWidth(); //browser width
  int y = d.getHeight(); //browser height
  int x2 = weD.getWidth() + ewp.getX();
  int y2 = weD.getHeight() + ewp.getY();
  return x2 &lt;= x &amp;&amp; y2 &lt;= y; 
  </code></pre>
  
  <p>If anyone has worked on it, Could you please share the solution?</p>