slide screen down

Asked by P4cha

I made a script that log onto my web site and send me report about site, but on one point I need to move screen (web-page) down to be able to click NEXT. I´m using Mac OS X and in order to do that I usually click somewhere on web site and press SPACE.

How can I do it in script.

click(screenshot, Key.SPACE or Key_SPACE)

I tried both and it´s not working, so if anybody knows other way to do it, please let me know.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

try to use type(), which simulates keystrokes.

if you know where to click:

click(somewhere)
type(" ")

keyboard-only normally its Command-Down to go to the end of something.
should work without clicking before (take care browser has focus! if not use switchApp(Browser) before)

type(Key.DOWN, KEY_CMD)

Revision history for this message
RaiMan (raimund-hocke) said :
#2

additional info:

together with click(something, modifier) there are only the modifier keys defined (KEY_SHIFT, KEY_CTRL, KEY_ALT, KEY_CMD and a combination using | (or)).

But this does not work in the moment: https://bugs.launchpad.net/sikuli/+bug/519916

Revision history for this message
P4cha (lafovi) said :
#3

Thanks RaiMan, that solved my question.

Revision history for this message
P4cha (lafovi) said :
#4

That was really helpfull, but if you know something about dropdown lists, and how can I press dropdown list and the chose something from this list, that would be great

Revision history for this message
RaiMan (raimund-hocke) said :
#5

switchApp("Safari")
dd = find(<image of your drop down in closed situation> )
if dd:
   click(dd) # opens list
   sleep(0.5) # to avoid timing problems
   type(Key.DOWN) # here goes your navigation
   type(Key.ENTER)
else:
   popup("Sorry, no dropdown found")

tested with the search criteria dropdown on the Sikuli answer page ;-)

you may find, that your dropdown entry is found even if the content is not exactly, what the image says.
To test different situations, produce these situations and then use preview (click on the image in the IDE). Play around with the similarity slider.

if you click ok, your image is turned into a pattern object (pattern(image).similar(decimal between 0 and 1).

You can use it directly (use instead of find(<image>):
find(Pattern(<image>).similar(0.8)) # the standard in the moment is 0.73
this means: only find images with a similarity of at least 0.8
This helped in the example to assure, that the dropdown was only clicked when showing: by relevancy.