← Back to team overview

sikuli-driver team mailing list archive

Re: [Question #228405]: Define region

 

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

RaiMan posted a new comment:
Ok, this might work now, but is always a bad idea to work with fixed regions like Region(551,325,499,342) (only for time of testing and trying to find the right solution).
Since this is on a webpage, the webpage must be always in the same position on screen.

And this function does not make any sense, since it has no parameters
and hence always does the same.

As a general approach with Sikuli, you should search in cases like yours
in regions, that you defend relative to some fixed images in your app.

I give you an example that uses the area at the top of this question
page:

goal:I want to click the edit button of Status:

header = "image of text Question Information.png"
# should have width of the whole area above the details
status = "image of text Status.png"
# should be wide  enough to span the edit button
edit = "image of edit button.png" #(there are more of them on the page)
mHeader = find(header)
rStatus = mHeader.below(50).find(status).below(30)
rStatus.click(edit)

or just in one statement (e.g. after having tested)
find(header).below(50).find(status).below(30).click(edit)

or if you want to reuse the header match as reference region more than once:
mHeader = find(header)
mHeader.below(50).find(status).below(30).click(edit)

and later might be
mHeader.below(50).find(language).below(30).click(edit)

or you use the target offset feature (Preview window) (preferable for fixed layouts)
click(Pattern(header).targetOffset(180, 55)) # clicks the edit button of status

the offset values depend on the center of the image and are evaluated
using the target offset tab of the preview window.

These examples always work independently of the location of the webpage
on the screen.

Want the example as working script:
https://dl.dropboxusercontent.com/u/42895525/relative-regions.sikuli.zip

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