Forum Discussion

cbahn001's avatar
cbahn001
Occasional Contributor
9 years ago

How to use keyword statement While Loop based on if an Onscreen Object is visible?

I am testing a desktop app and trying to use a while loop to run a series of steps if an object is visible on screen, in this case it is an error that shows up if I a username has been used.  Right now I have tried the verifying the object is enabled when that did not work I tried verifying the object was visible.  Both in both cased the test did not recognize the object on screen and jumped out of the loop. 

 

My loop details are set as follows

 

Aliases.LocationManager.HwndSource_Window3.WindowLocationManagerQaHw20151Version11431.PrismShellWindowContent.ContentRegion.ModalRegionsControl.MainContainer.DockPanel.ContentRegion.SPMContentRoot.Grid.SPMContentRegion.DefaultViewUserControl.BarManager.RootPanel.RootLayoutManager.LayoutRoot.Properties.ContentControl.Site.LayoutRoot.DockPanel.SiteInformationExpander.ContentPresenter.Border

 

Equals

 

Aliases.LocationManager.HwndSource_Window3.WindowLocationManagerQaHw20151Version11431.PrismShellWindowContent.ContentRegion.ModalRegionsControl.MainContainer.DockPanel.ContentRegion.SPMContentRoot.Grid.SPMContentRegion.DefaultViewUserControl.BarManager.RootPanel.RootLayoutManager.LayoutRoot.Properties.ContentControl.Site.LayoutRoot.DockPanel.SiteInformationExpander.ContentPresenter.Border.Visible

 

If I change the condition to “Does Not Equal”, then the test stays within the loop running the steps over and over again.

 

Any help on how to successfully perform a While Loop based on Onscreen Object would be appreciated.

 

Thanks,

Chris

  • djadhav's avatar
    djadhav
    9 years ago

    Since you say "So basically I am trying to enter a unique record into a database through the application". Can we assume your goal is to have a unique name every time? If yes, then you can eliminate the While loop totally.

     

    There are multiple ways to do this:

     

    Using Project Variables:

    Create a Project Level variable (https://support.smartbear.com/viewarticle/77783/) to keep a track of the last value used to create the name.

    Every time

    1) Fetch the value

    2) Increment it by one and use it to create a unique name

    3) Store the new value back to the Project variable.

     

    Using TimeStamp:

     

    Append this to the Name to get a unique value everytime.

     

    NewValue = OldValue + aqConvert.DateTimeToFormatStr(aqDateTime.Now(), "%m%d%y%H%M%S")

10 Replies

    • cbahn001's avatar
      cbahn001
      Occasional Contributor

      djadhav,

      I have attached two screenshots one is the keyword steps I am performing in TC and the second is of the application, error that stats "A site named "AutomatedTest1" already exists"  is what i am trying to verify is visible.  If I highlight this object from within the while loop to test that it can find it, tesct complete successfully highlights the object.  Also if I change the While Loop to does not equal the test jumps into the loop and successfully runs through the steps but is not able to break out of the loop.

      Thanks,

      Chris 

      • djadhav's avatar
        djadhav
        Regular Contributor

        So you're trying to do this:

         

        While (Object is Visible)

              Do something

         

        Can you simply state (as above) where exactly are you facing an issue?