click dynamically

Asked by akbar

Records are displayed in a table and the requirement is to click on any one record. Each record has an ID which is generated dynamically during the execution. ID value is known before clicking on it, but how to create an image for the ID text and then click on it? Please advise.

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

If you are a Java programmer and know the font, than you can create a buffered image and use it to search.

On the plain Sikuli script level there is no possibility for this.

But you say:
the requirement is to click on any one record

So if you know the position of the first record (first = Location(x,y)), the heigth of each entry and the number of records:

height = h # to be evaluated somehow
first = Location(x,y) # the click point for 1st rec, evaluated somehow
count = n # number of records

for i in range(count):
    click(first.below(i*height))
    # do what's needed

Revision history for this message
akbar (mohammed-akbar-ali) said :
#2

The record may not be the first record. How to click on 12345?

Example:-
ID
11000
12000
12341
12345
12346
12347

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

If the numbers can be read correctly using Region.text(), then you might try click("12345") which internally uses the text search feature (but be aware: bug 710586)

Revision history for this message
akbar (mohammed-akbar-ali) said :
#4

RaiMan, Thanks for reply. Your previous solution worked. What i observed is that region.text() works consistently after click() is performed on the required region.

Revision history for this message
akbar (mohammed-akbar-ali) said :
#5

Thanks RaiMan, that solved my question.