title: Selenium code to scroll Horizontally in a web-element which is loading lazily
body: <p>Can someone help me to write a selenium code to find an element inside div by scrolling horizontally when it (the element) is loading lazily.</p>
  
  <p>For example in the following URL the elements are laoded after we scroll right : </p>
  
  <ol>
  <li><a href="http://ressio.github.io/lazy-load-xt/demo/horizontal.htm" rel="nofollow noreferrer">http://ressio.github.io/lazy-load-xt/demo/horizontal.htm</a></li>
  <li><a href="http://www.appelsiini.net/projects/lazyload/enabled_wide_container.html" rel="nofollow noreferrer">http://www.appelsiini.net/projects/lazyload/enabled_wide_container.html</a> </li>
  </ol>
  
  <p>I have tried :</p>
  
  <pre><code> 1. ((JavascriptExecutor) driver).executeScript("window.scrollTo(&lt;x-corodinate&gt;,&lt;y-coordinate&gt;)");
   2. ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView();", element); 
   3. ((JavascriptExecutor) driver).executeScript("window.scrollBy(&lt;x-corodinate&gt;,&lt;y-coordinate&gt;)");
   4. ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
  </code></pre>
  
  <p>But was not solving my purpose.</p>
  
  <p>I am using java 1.8 , selenium jar version is 3.0.1 and Firefox 50.0.2.  </p>
  
  <pre><code>File driverPathFirefox = new File("PATH \\TO \\ Driver \\geckodriver.exe");
  System.setProperty("webdriver.gecko.driver",driverPathFirefox.getAbsolutePath()); 
  WebDriver driver = new FirefoxDriver();
  driver.manage().timeouts().implicitlyWait(25000, TimeUnit.SECONDS);
  driver.manage().window().maximize();
  driver.navigate().to(URL);// URL could be the one referred in the question
  WebElement scrollArea = driver.findElement(By.xpath(&lt;Xpath of the div&gt;));
  // Capturing xpath of div from the URL referred above 
  // xpath for div in http://ressio.github.io is "html/body/div[1]/div[2]"
  // xpath for div in http://www.appelsiini.net is ".//*[@id='container']"
  
  // Now here I need the code to scroll the web element horizontally 
  // until desired element is visible.
  
  driver.quit();
  </code></pre>
  
  <p>Selenium dependencies are :</p>
  
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
          &lt;artifactId&gt;selenium-java&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.seleniumhq.selenium&lt;/groupId&gt;
          &lt;artifactId&gt;selenium-api&lt;/artifactId&gt;
          &lt;version&gt;3.0.1&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>