← Back to team overview

sikuli-driver team mailing list archive

[Question #175489]: find works better if I highlight the search region first

 

New question #175489 on Sikuli:
https://answers.launchpad.net/sikuli/+question/175489

I am testing a Visual Studio plug-in, and want to make sure a debug session stops at the correct location.  What I am finding is that if I do NOT sRegion.highlight(2) first, sRegion.exists(myImage) returns a match at the wrong location.  Is there something I'm missing that highlight does?

        # look for source tab and make sure it has focus
        if not exists("SobelFilterKernelSourceTab.png"):
            SFTest.updateFailures(messagePrefix, "debugger did not stop at the correct location", "testBreakpoint")
            status = 0
        else:
            tab = Region(getLastMatch())
            click(tab)
            # set the source view to the expected break line
            type("g", KEY_CTRL)
            type("103\n")
            # narrow down search region
            sRegion = tab.below()
            # sRegion may not contain where we really want to search; blame MS Visual Studio
            # making region wider
            oldX = sRegion.getX()
            newX = oldX - 200
            oldW = sRegion.getW()
            newW = oldW + 400
            sRegion.setX(newX)
            sRegion.setW(newW)
            # confirms that I've got the right search region
            sRegion.highlight(3)
            # look for the line number in sRegion
            # this works if I do the above highlight, but gets a wrong match if I don't
            # Image is just white background and blue number 103
            # looking for the text "103" seems to get the wrong match, too
            sLine = sRegion.exists("SobelFilter_103_sobel_filter.png",10)
            if not sLine:
                SFTest.updateFailures(messagePrefix, "Sikuli did not find the breakpoint location", "testBreakpoint")
                status = 0
            else:
               # just making sure I got the right line
                sLine.highlight(3)
                # codeRegion is in the source code view
                codeRegion = sLine.right(300)
               # arrowRegion is where VS displays the Next Statement arrow
                arrowRegion = sLine.left(75)
               # just making sure I made the regions the right size
                codeRegion.highlight(3)
                arrowRegion.highlight(3)
                print "Checking for arrow"
                if not arrowRegion.exists("NextStatementArrow.png"):
                    SFTest.updateFailures(messagePrefix, "debugger stopped at an unexpected source line", "testBreakpoint")
                    status = 0
                print "Checking for source text"
                if not codeRegion.exists("{", 5):
                    SFTest.updateFailures(messagePrefix, "debugger stopped at the wrong source line", "testBreakpoint")
                    status = 0

-- 
You received this question notification because you are a member of
Sikuli Drivers, which is an answer contact for Sikuli.