So I worte this function and sometimes its able to grabbed the text in table and sometimes it doesnt

Asked by Ali Ahmed on 2021-02-13

So I want it to run consistently, i dont understand why it's not able to grabbed the text in column. This is the function I am using:

def copyBookOutsTableTradeID():
    print "Copy Trade ID in Bookouts"
    r=Region(218,195,209,148)

    wait(.5)
    click(Location(509, 227))
    x=r.find("SRCTradeIDHeader.png").below(51).highlight(.5).text()

    print("ID is "+x)
    return x

Question information

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

tested and did not have a problem.

your approach principally works.

You have to check seperately, wether text() has a problem with your text:

a oneliner:
print selectRegion().text()

Revision history for this message
Ali Ahmed (ali13xii) said :
#2

So I tried it with using the one liner and its able to read the text in the table but sometimes its unable to. I ran several times and it doesn't occur frequently but occasionally it will print nothing as the output when it should be showing me a value

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

Ok, that is a problem with SikuliX's OCR: it sometimes fails.

You have to catch the failing cases and check, what might be different.

Revision history for this message
Ali Ahmed (ali13xii) said :
#4

I am capturing when its failing, the image the same as the one when it passes. When I tried it with the one line of code it does read the text and print it; but when I tried it about 15 times I did get a few fails where it didn't print anything.

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

Sorry, but if you do not find any differences between running and failing samples, then I cannot help you.

might be, that 2.0.5 (March 1st) brings some enhancement.

Can you help with this problem?

Provide an answer of your own, or ask Ali Ahmed for more information if necessary.

To post a message you must log in.