How to scroll down with sikuli

13,020

Solution 1

You can simply use shortcuts:

Windows Example:

type(Key.PAGE_DOWN) - scroll down 1 time
type(Key.PAGE_UP) - scroll up 1 time

Also if you want to repeat it a few times:

type(Key.PAGE_DOWN*3) - scroll down 3 times

MAC Example:

type(Key.DOWN, KeyModifier.CMD) - scroll all the way down

NOTE: If you really want to scroll down with the mouse wheel:

Mouse.wheel(WHEEL_UP, 1)
Mouse.wheel(WHEEL_DOWN, 2)

Solution 2

First of all, it has nothing to do with Sikuli. Second, keep in mind that the commands are being executed one by one and do not wait for the actual operation on the screen to complete. It is important to allow sufficient time for whatever it is you are trying to do to fully complete before calling the next command. By failing to do so, you are risking in ending up with a chaotic, inconsistent behavior. So just to find the culprit of you current issue, insert an explicit wait between all of your commands and also visually verify that each command is executed only after the previous one has completed. So you can insert something like this:

Thread.sleep(timeInMs);

Other thing to try scrolling using keyboard instead of the less reliable mouse scroll. You can do that like this:

s.type(Key.PAGE_DOWN);
Share:
13,020
Admin
Author by

Admin

Updated on June 05, 2022

Comments

  • Admin
    Admin almost 2 years

    How to scroll down with Sikuli in Selenium Eebdriver with java?

    I am using screen.wheel(1 , 8); in my code to scroll down in an open window.

    Sometimes it works fine but after running my script 4-5 times it behaves differently. Instead of scrolling vertically it starts scrolling horizontally.

    s.doubleClick("C:\\SikuliX\\Images\\C_Drive.png");
    s.wheel( 1, 8); 
    s.doubleClick("C:\\SikuliX\\Images\\DestinFolder.png");
    s.doubleClick("C:\\SikuliX\\Images\\CfgFolder.png")
    

    Please help and let me know how I can move the scrollbar vertically for specific steps and in particular window.