Scrolling does not work in Internet Explorer

I tried scrolling (x, y) using javascript in Internet Explorer 10. But this did not work when I tried to execute the script for the website. What is equivalent to the same in IE? This is part of the Java Selenium test. I need to scroll the page. So, I do this by executing javascript code using a javascript executor.

for(int i=0;i<X;i+=Y)   
String cmd = "window.scrollTo(0,"+i+")";    
((JavascriptExecutor) driver).executeScript(cmd);

I use the above code in my test to scroll the page. But in Internet Explorer IE10, it does not work.

+4
source share
4 answers

The correct syntax will be window.scrollTo(xpos,ypos). This works in all major browsers, read about the feature here .

+2

scrollIntoView

JavascriptExecutor jse=(JavascriptExecutor)driver;
jse.executeScript("document.getElementById(<id>).scrollIntoView(true)");

. window.scrollTo JS .

+2

I had the same issue, but with IE 9.

I found that

executeScript("window.scrollTo(0,100)")

doesn't work but

executeScript("window.scrollTo(0,100);")

did the job. Note ";" at the end of the executed command.

0
source

There seems to be a problem with the JavascriptExecutor in some versions of IE10. Here you can find a possible workaround, but I have not tried it myself.

0
source

Source: https://habr.com/ru/post/1541779/


All Articles