Forum Discussion

mengbinhao's avatar
mengbinhao
Contributor
7 months ago
Solved

Script can not goto else branch

Hi All,    I use Javascript for the automation of my target Desktop application,  Below is my code snapshot,  what confuses me is if the result of condition 1 is false (TC throw error: window1 does ...
  • rraghvani's avatar
    7 months ago

    In order to check the property value of VisibleOnScreen, the object window1 must exist. You can test via the following code,

    if (window1.Exists) {
      if (window1.VisibleOnScreen) {
        doSomething1()
      } else if (window2.VisibleOnScreen) {
        doSomething2()
      } else {
        doSomething3()
      }
    } else {
      Log.Warning("window1 does not exist.")
    }

     ...also need to check the existence of window2.