Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scroll down with sikuli

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.

like image 502
Jazz Avatar asked Jun 28 '17 16:06

Jazz


People also ask

How do you click on Sikuli?

Sikuli Methods: Double click on an element: screen. doubleClick(“path of your image”); Right click on an element: screen. rightClick(“path of your image”);

How do I use Sikuli in Python?

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.

How does Sikuli selenium work?

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.


2 Answers

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)
like image 192
Assi.NET Avatar answered Oct 09 '22 16:10

Assi.NET


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);
like image 1
Eugene S Avatar answered Oct 09 '22 16:10

Eugene S