App.focus failed: xxxxxxx.exe not found

Asked by Aki Sivula

Hi,

I'm trying to handle Windows .NET app crash case on automatic tests but got a problem with App.focus(). By some reason Sikuli's Message log contains always this error with red color even I try to handle such case with if statement. I'm not sure whether this is ok or not. Just want that crash is handled if exists and if not then continue.

Crash happens only sometimes and application close dialog goes behind the frozen window and sometimes not. Sometimes crash handling is needless and code executes crash handling just in case if app frozes or something unexpected happens. Trying to create as simple crash handling as possible.

Error:
[error] App.focus failed: ap15vNET.exe not found

crash handling code:
def handlecrash(app_name):
  try:
      # check if exists before set the focus
      if exists(App.focus(app_name + ".exe")):
          # set focus
          App.focus(app_name + ".exe")
          print "Form: "+ app_name + ".exe" + " fokus set."
      else:
          print "Form: "+ app_name + ".exe" + " not found."
  except:
      pass

# dialog is closed with clicking the close button
  try:
      # wait until crash dialog vanishes and then click close button
      wait("crash_closebtn_gfx.png",5)
  except:
      pass
  else:
      click("crash_closebtn_gfx.png")

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Best RaiMan (raimund-hocke) said :
#1

--- if exists(App.focus(app_name + ".exe")):
exists() needs an image as parameter - so this will never work.

Try to use the App.window() features are make your validation using images.

Revision history for this message
Aki Sivula (aki-sivula) said :
#2

Thank you. App.Window solved the issue.

Revision history for this message
Aki Sivula (aki-sivula) said :
#3

Thanks RaiMan, that solved my question.