I am trying to automate a test suite by using selenium IDE, the idea its to generate the tests with the IDE and then export them to a java/jUnit format. The problem its that the the tests generated in the IDE behaves slightly different than in java code.

In particular this is what I have pointed out: When I record a test and play it Selenium IDE scrolls automatically in order to make visible the element. But the java generated code doesn't do this. This is the test case in the IDE. enter image description here

and this its the exported code, as you will see selenium IDE isn't generating any instruction to scroll, like Scroll Element into View with Selenium in fact we need the code to work as its generated and without any modification. Is there any way to configure selenium (via maven or overriding some code) in order to perform a scroll right before any interaction with the element? I know I can add js in the selenium IDE, but we want the process to be as codeless as possible.

import org.junit.Test;
import org.junit.Before;
import org.junit.After;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.core.IsNot.not;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Alert;
import org.openqa.selenium.Keys;
import java.util.*;
import java.net.MalformedURLException;
import java.net.URL;

public class TestScrollTest {
  private WebDriver driver;
  private Map<String, Object> vars;
  JavascriptExecutor js;

  public void setUp() {
    driver = new ChromeDriver();
    js = (JavascriptExecutor) driver;
    vars = new HashMap<String, Object>();

  public void tearDown() {

  public void testScroll() {
    driver.manage().window().setSize(new Dimension(1382, 744));
    driver.findElement(By.cssSelector(".card:nth-child(1) > div")).click();
    driver.findElement(By.cssSelector(".element-group:nth-child(1) .header-wrapper")).click();
    driver.findElement(By.cssSelector(".element-group:nth-child(1) .header-wrapper")).click();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.