понедельник, 19 марта 2012 г.

Sikuli: convenient way for debugging

When you debug your Sikuli script it is not easy to understand what image pattern sikuli can't find. Usually you see something like this log:

org.sikuli.script.FindFailed: FindFailed: can not find 1325480980510.png on the screen.


So you need or rename all patterns or open folder with patterns and see what the picture patter wasn't found.

It is not a simple way for debugging your script, so how I solved this problem will be below...


 #Here we get the path of our script 
  
 p=getBundlePath()
  
 try:
  
 click("1332145210797.png")
  
 # Our long script...
  
 except:
  
 #If somethinh is wrong we need to get in string exception
  
 myString=str(sys.exc_info())
  
 #Cut from log message our pattern filename
  
 mySubString=myString[myString.find("find ")+5:myString.find(" on")]

#Add for project path pattern's filename
  
  p = p + "\\" + mySubString

#Open pattern
  
  import os
  
 os.popen('start '+p)  
So you will always see what Sikuli can't find! 

Комментариев нет:

Отправить комментарий

javascript:void(0)