Mark1
6 years agoContributor
If statement for VisibleOnScreen is failing when object is not on screen
I have a method where if the a specific dialog box is VisibleOnScreen it will click the ok button and carry on else it just carries on as normal. This dialog box is just a warning that the software b...
- 6 years ago
Replace
If Sys.Process("SoftwareBeingTested").WPFObject("HwndSource: PopupRoot", "").WPFObject("PopupRoot", "", 1).WPFObject("Decorator", "", 1).WPFObject("NonLogicalAdornerDecorator", "", 1).WPFObject("Grid", "", 1).Exists
with
If Sys.Process("SoftwareBeingTested").WPFObject("HwndSource: PopupRoot", "").WPFObject("PopupRoot", "", 1).WPFObject("Decorator", "", 1).WPFObject("NonLogicalAdornerDecorator", "", 1).WaitWPFObject("Grid", "", 1, 20000).Exists
Again, same deal... WPFObject("Grid", "", 1), if it doesn't exist, doesn't even have the property "Exists". You can't check a property of an object where there is no object... so, you need to utilize code to return something FIRST to determine if it exists.