Validating a dropdown list

Asked by HichMich

Hi everyone, i'm new to sikuli here. However I'm used to python and java programming so i could get a hold of it pretty easily. My concern is that i need to validate my data fields entered on a desktop app, and i'm struggling with drop down lists. I understand the trick to validate normal textfield by using tabs and copying the data to the clipboard, however for drop down lists i don't see how i can find a reliable way to validate the data.

What i tried so far :
-select my drop down list with sikuli and perform Key.DOWN until i'm at the bottom of the list (the idea is if i know how many keystrokes i've made to get to the end of the list i could tell what was the item selected in the first place). I couldn't make it work because i couldn't make a condition that would check for end of scroll within the list.

Any ideas ?

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

Just make a shot of the current drop down entry field before Key.DOWN, then type Key.DOWN and then compare the shot made before with the current content of the match region:
if equal, you are at the end, if not, some fields are left.

field = Region(<some how evaluate the (field) region to observe>)

# the following snippet will be somewhere inside a loop

imgField = capture(field) # now you have saved the image before KeyDown
type(Key.DOWN)
if field.exists(Pattern(imgField).exact(), 0):
    print "the end is reached"
    break
else:
    continue # her you have to do something and go back to top of loop

Since you say you are familiar with Python, I did not write exact code, hoping you get it

comment on exists(<some image>, 0):
The 0 tells Sikuli, to come back immediately after the first image search and not wait the standard 3 seconds if not found.

Hope you are using the new version 1.0.1 ;-)

Revision history for this message
HichMich (hicham-chraibi) said :
#2

Thank you very much for this solution, works like a charm :)

Revision history for this message
HichMich (hicham-chraibi) said :
#3

Thanks RaiMan, that solved my question.