Forum Discussion

dcfecker's avatar
dcfecker
Contributor
7 years ago
Solved

Looking for a better way to activate a button if it exists

For each of my automation tests run, I have to ensure if certain items exist, they are removed, so I can create them new. One is the LongPressableButton indicated in the following code:   longPress...
  • NisHera's avatar
    7 years ago

    Exists method dose only wait for project defined waiting time.

    hence you don't have individual control of timing.

    In your problem it seems it take time for object to be created.

     

    So I think it good to use FindEx method.

    Other good thing is it will not fire error message so you can control in the way you need.

     

    you can do some thing like........

    longPressableButton = replayMainWindow.aoiShortcutButtonContainer.FindEx("PropName", "PropValue", 10, True, 5000)
    if (longPressableButton.Exists) {
    longPressableButton.ClickR();
    replayMainWindow.HwndSource_PopupRoot.PopupRoot.deleteButton.Click();
    replayMainWindow.Canvas.Grid.ItemsControl.SurfacebuttonYes.Click();
    } else {Log.Warning('LongPressable not exist going for next button')}

    Remember to replace propName and PropValue with actual property and values of button