← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #692519]: findChanges has no function

 

Question #692519 on Sikuli changed:
https://answers.launchpad.net/sikuli/+question/692519

    Status: Open => Answered

RaiMan proposed the following answer:
---  does not highlight the word "findChanges"
This is because the word is missing in the respective IDE support file (as many other features)

Relevant is, whether something like someRegionOrWhatever.someFunction()
does not lead to a name error.

--- this is a findChanges test on Windows having the page
https://github.com/RaiMan open in Google Chrome and triggering changes
by selecting a different tab

App.focus("Google Chrome")
wait(2)
#observe area in app window
reg = App.focusedWindow()
reg = reg.grow(-10, -540, -150, -30)
reg.highlight(1)
# put the app window in an startup state
if not reg.has("1598188841340.png"):
    btnOver = "btnOver.png"
    reg.click(btnOver)
    reg.wait("1598188674947.png", 10)
# capture startup state
img1 = capture(reg)
# chnage the content in the observed area
btnRepo = "img.png"
reg.click(btnRepo)
reg.wait("1598188724213.png", 10)
# capture changed state
img2 = capture(reg)

# evaluate changes
f = Finder(img1)
changes = f.findChanges(img2)
print "changes:", len(changes)
changed = Region(0, 0, reg.w, reg.h)
if len(changes) > 0:
    changed = changes[0]
    if len(changes) > 1:
        for change in changes[1:]: 
            changed = changed.union(change)
changed = Region(reg.x + changed.x, reg.y + changed.y, changed.w, changed.h)
changed.highlight(2)

The result is 29 changes, which result in a changed area union in the
right side of the page (as expected).

Hence, findChanges works as expected.

Be aware: in the current implementation (which surely has to be enhanced
;-) this is the safest way:

Finder(absolute-filename-string-base).findChanges(absolute-filename-
string-changed)

which in my testcase is assured by using capture(reg).

-- 
You received this question notification because your team Sikuli Drivers
is an answer contact for Sikuli.