Novice: How to include page down key

Asked by marcus

Apologies beforehand for asking what I am sure is a very obvious question but having just found sikuli last night although I don't know the first thing about programming I could see it would be very useful to disabled people like me.

I want to setup a program to use a facebook applicaion but at one point I need to press the 'page down key'

I have tried:
key.PAGE_DOWN
key(PAGE_DOWN)
key(PAGE_DOWN);

None of which work and the grey highlight turns to red (which I assume shows its bad code). None of the example I could find include how to add a key stroke like this so can someone please help?

Many thanks
Marcus

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Sergey Darovskih
Solved:
Last query:
Last reply:
Revision history for this message
Best Sergey Darovskih (darovskih) said :
#1

type(Key.PAGE_DOWN)

Revision history for this message
marcus (marcus-webmail) said :
#2

Thanks Sergey Darovskih, that solved my question.

Revision history for this message
Julie Merriman (julie-merriman) said :
#3

I'm trying to use this for a browser application but type(Key.PAGE_DOWN) doesn't work (I get an error on the line). Is there anything else I need to add or be aware of? Immediately preceeding this, I have entered text into a field - so my code is as follows:

type(screenshot,"Test Ad for Automated Testing\n")
type(Key.PAGE_DOWN)

Thanks

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

exactly as it should be.

what system?

what error do you get? paste message.

Revision history for this message
Julie Merriman (julie-merriman) said :
#5

Thanks here's the info ...

Windows XP 2002 SP3
Browser = Firefox 3.6.17

Ran it again, code is as follows:

13 type( ,"Test Ad for Automated Testing")
14 type(Key.PAGE_DOWN)
15 type( ,"07771 888777\n")

at line 13 - the text goes in correctly
at line 14 - no page down is seen visually on screen (page down is required to see field referenced in line 15)
at line 15 - errors as follows:

 org.sikuli.script.FindFailed: FindFailed: can not find inc.png Line 42, in file C:\DOCUME~1\JULIEM~1\LOCALS~1\Temp\sikuli-tmp4517480408878126318.py

Revision history for this message
Julie Merriman (julie-merriman) said :
#6

... and Sikuli X-1.0rc2

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

@Julie

*** possible reason 1: the page-down is not accepted, because you are still in the entry field

or did you miss the \n in this post?

recommandation: use
type( ,"Test Ad for Automated Testing"); type(Key.Enter)

this is more readable.

*** possible reason 2: timing problem

the webpage may need some time to prepare for the next key press.

try this:
type(some-image ,"Test Ad for Automated Testing"); type(Key.Enter); wait(0.5) # give time to web page
type(Key.PAGE_DOWN); wait(1) # give time to scroll down
type(some-other-image ,"07771 888777\n")

*** general comment for other questions
do not ask additional questions by adding comments to already solved ones.
just start a new question.

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

sorry: it has to be type(Key.ENTER)

Revision history for this message
Julie Merriman (julie-merriman) said :
#9

I tried the following as per suggestion 2 but still not seeing screen move visually and getting the error on line 15:

org.sikuli.script.FindFailed: FindFailed: can not find inc.png Line 42, in file C:\DOCUME~1\JULIEM~1\LOCALS~1\Temp\sikuli-tmp147728760420108418.py

12 type(some-image,"Sikuli Test\n")
13 type(some-image,"Test Ad for Automated Testing"); type(Key.ENTER); wait(0.5) # give time to web page
14 type(Key.PAGE_DOWN); wait(1) # give time to scroll down
15 type(some-image,"07771 888777\n")

(ps will start new question in future, thx)

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

Uuups, do not know whats up :-(

try the following (more info: http://sikuli.org/docx/region.html#exception-findfailed):

setFindFailedResponse(PROMPT)

at the beginning of your script.

When coming to line 15, this will bring up a prompt message.

Try to manually use the page-down to see if it works in this situation (click the web page first, the prompt steals focus ;-)

If it does, you can use "Retry", to continue the script.

Revision history for this message
Julie Merriman (julie-merriman) said :
#11

I added the prompt at the beginning.

At line 15 it did indeed bring up a prompt - so I manually paged down and clicked Retry and the script completed successfully.

I will use this for now - my alternative has been to use the following for it to manually slowly scroll down - but a bit painful to watch ;-)

for n in range(0, 40):
 click(image_of_scrollarrow)

Thanks for your speedy response today.

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

no idea, why page_down does not work in your situation. I tested on my Win7/FF4 and had no problems with a workflow like yours.

you could give wheel (http://sikuli.org/docx/region.html#Region.wheel) a try.

--- comment on your solution:

for n in range(0, 40):
 click(image_of_scrollarrow)

this might be faster:
m = find(image_of_scrollarrow)
for n in range(40): click(m)

the implicit search behind your repeated click costs about 0.5 seconds each when searching the whole screen.

Revision history for this message
Scott (scottquote) said :
#13

I don't know if this helps but.....
Make sure the window has the focus. click(anywhere) on the window, then try the rest.