wait("file.png") returns too soon

Asked by Beth Griffin

I am writing a script that drive Microsoft Visual Studio.

I need to wait on occasion for the debugger to hit a breakpoint, so I created snapshot of the expected breakpoint so that the image contains:

the yellow "Next Statement" arrow
the line number of that statement
the line number above
the line number below

So it looks sort of like:

         141
-> 142
         143

I then do a

wait("breakpoint_142.png")

However, the wait comes back with the image as found before the breakpoint is actually hit. Like it decides that matching the line numbers is enough, and the yellow arrow is meaningless.

So I tried

wait(Pattern("breakpoint_142.png").exact()),

But this give me a FindFailed exception, even though this is clearly on the screen.

Any suggestions?

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Beth Griffin
Solved:
Last query:
Last reply:
Revision history for this message
Beth Griffin (beth-griffin) said :
#1

FYI, before suggesting I search a smaller region, trying to determine the region isn't easy. As Visual Studio runs, the placement of where this image will show up the next time I run the test may not be the same. I suppose I could use a "wait(<seconds>)", but if performance changes, I'm either waiting too long, or not long enough, hence the wait for a particular image. The thought was with an image this small, I removed the ambiguity (less text, more graphics), but it doesn't seem so.

Revision history for this message
Beth Griffin (beth-griffin) said :
#2

I think I solved my own problem:

wait("file.png")
wait(3)
type("v", ...

Apparently, with Visual Studio, I need to give it more time than to just have the image visible.

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

---1: using exact()
seems to make problems. try using similar(0.99) instead

---2: smaller region
a smaller region always makes things better. In this case, this could be the region representing the column, containing the breakpoint symbol and the line numbers. this should be fixed with reference to the app window.

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

Another possibility is, to first position on the line numbers and then look for the symbol to the left.

In such critical situations I always analyze the similarity values of different matches, to decide on the similar() value to use.