0

The code is:

WebElement element=driver.findElement(By.xpath("//div[@class='table-wrapper']"));
JavascriptExecutor js=(JavascriptExecutor)driver;
js.executeScript("arguments[0].scrollLeft=arguments[0].scrollWidth", element);

While debugging at third step, executeScript returned me "null".

Xpath is correct and locating well. I can't able to find locator of scroll so I am using whole locator of that particular div. i.e //div[@class='table-wrapper'].

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Max Brian
  • 21
  • 4

1 Answers1

0

Instead of scrollLeft you can always Element.scrollIntoView() as follows:

WebElement element=driver.findElement(By.xpath("//div[@class='table-wrapper']"));
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);

You can find a relevant detailed discussion in scrollIntoView() not working for horizontal scroll (Selenium)

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352