0
votes

I'm totally a newbie in terms of using Selenium ide or any automation testing tool. Now i'm stuck with this scenario: after testing elements 1 & 2 on top of the page, i need to scroll down a bit to test the elements just below 1 & 2. I've read something about using while and endWhile commands but you have to insert user-extension.js file first. [Link: http://www.software-testing-tutorials-automation.com/2013/09/how-to-generate-mouse-scrolling-event.html]. Problem is, it doesn't work. Any help guys? Thanks much!!

1
What do you want to do exactly? You dont have to scroll 'manually', selenium should do it automatically if you want for example click element - kotoj
Have a look here: stackoverflow.com/questions/13488359/… This worked fine for me - Jsmith2800

1 Answers

0
votes

you can use javascript scroll down the page :

public void javaScriptToScrollDownPage(WebDriver driver, String coordinatevalue) throws KDTKeywordExecException {
        try {
            ((JavascriptExecutor) driver).executeScript("scroll(0, " + coordinatevalue + ")");
        } catch (Exception e) {
            throw new KDTKeywordExecException("Not able to scroll down the page", e);
        }
    }

I have created as a function, can use this. You have to change the coordinate value ie how much you want to scroll down

Similarly for scrolling up:

public void javaScriptToScrollUpPage(WebDriver driver, String coordinatevalue) throws KDTKeywordExecException {
        try {
            ((JavascriptExecutor) driver).executeScript("scroll(" + coordinatevalue + ",0)");
        } catch (Exception e) {
            throw new KDTKeywordExecException("Not able to scroll up the page", e);
        }
    }