What's the command to take a picture in Sikuli

Leonardo Sobral picture Leonardo Sobral · May 25, 2013 · Viewed 21.9k times · Source

I'm using Sikuli IDE. I'd like to know what the command to take a screenshot is, so I can capture the screen at the end of a test.

Something like this

try :
  if bla bla bla:
    print("blablabla")
  else:
    TAKESCREENSHOT()  #------------------> What command do I put here?
  print("TEST_FAILED")

Answer

Nathaniel Waisbrot picture Nathaniel Waisbrot · May 25, 2013

The function is capture, as in

screen = Screen()
file = screen.capture(screen.getBounds())
print("Saved screen as "+file)

It takes a screen-shot, saves it in a file, and gives you the path to that file back.

See the Sikuli documentation on it for full details.