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
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")