Screenshot on error

Asked by sandeep

I would like to take a screenshot on error, any idea if the 1,1 in sikuli has something inbuilt?, if not what is recommended way to take screenshot on error.

Thanks in advance.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
Eugene S
Solved:
Last query:
Last reply:
Revision history for this message
Eugene S (shragovich) said :
#1

Hi,

This is how I take my screenshots:

def takeScreenShot(application):
 img = capture(SCREEN) # img is an image file .png in temp folder now
 ts = time.time()
 st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d_%H-%M-%S')
 if not os.path.exists('PATH'):
  os.makedirs('')
 shutil.move(img, 'PATH\\%(appName)s\\%(timeStamp)s.png' %{"appName": application, "timeStamp": st})

Revision history for this message
sandeep (sbaldawa) said :
#2

Thanks, what does "SCREEN" mean here in capture(SCREEN)?

How do I call this function i.e. what value do I pass for application?

Revision history for this message
Eugene S (shragovich) said :
#3

SCREEN means the whole screen rather than a region that you could also pass as an argument to "capture()".
Just use it as is.

Revision history for this message
sandeep (sbaldawa) said :
#4

Thanks a lot, sorry but still did not getwhat to pass to takeScreenShot function as parameter, I would like ideally to take snapshot of the entire App in focus.

Revision history for this message
Best Eugene S (shragovich) said :
#5

Oh, sorry. Now I see what are you asking :)
In my case I just supply the name of the current test to keep the screenshots in order. So basically it is just any text string.

Revision history for this message
sandeep (sbaldawa) said :
#6

Thanks Eugene S, that solved my question.

Revision history for this message
sandeep (sbaldawa) said :
#7

Thanks a lot again.