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.
Sikuli Methods: Double click on an element: screen. doubleClick(“path of your image”); Right click on an element: screen. rightClick(“path of your image”);
You can run SikuliX scripts using <path-to-jython>/bin/jython <path-to-youNameIt. sikuli>/youNameIt.py . In a Python IDE you have to setup your project according to the rules.
Sikuli is an open-source GUI based test automation tool. It is mainly used for interacting with elements of web pages and handling windows based popups. Sikuli uses the technique of “Image Recognition” and “Control GUI” to interact with elements of web pages and windows popups.
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)
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With