Saroj Purbey
Saroj Purbey

Reputation: 280

Automatic Horizontal scroll not working in Selenium

I have tried many codes but none worked for me.The site is built in Angular.

WebElement columnElement = driver.findElement(By.id("i301Indv"));
((JavascriptExecutor)getDriver()).executeScript(
    "arguments[0].scrollIntoView(true);", columnElement);


WebElement columnElement = driver.findElement(By.id("i301Indv"));
((JavascriptExecutor)getDriver()).executeScript(
    "arguments[0].scrollIntoView();", columnElement);


WebElement columnElement = driver.findElement(By.id("i301Indv"));
((JavascriptExecutor) driver).executeScript(
    "arguments[0].scrollLeft = arguments[0].offsetWidth", columnElement);

Upvotes: 1

Views: 495

Answers (1)

Success Shrestha
Success Shrestha

Reputation: 443

Try this:

Actions actions = new Actions(Webdriver);
actions.moveToElement(webElement).click().build().perform();

This will find the element, move to that element and perform the click operation.

Upvotes: 1

Related Questions