Coded UI Control.Exists. System.NullReferenceException

后端 未结 2 2015
野趣味
野趣味 2021-01-24 05:45

I want to check that window exists after some actions. I try:

 protected override Boolean IsPresent()
    {
        if (_mainWindow == null)
        {
                   


        
2条回答
  •  庸人自扰
    2021-01-24 06:19

    Exists is not what you want to use. You can use TryFind() instead.

     protected override Boolean IsPresent()
     {
         if (_mainWindow == null)
         {
             _mainWindow = new WinWindow();
             _mainWindow.SearchProperties[WinWindow.PropertyNames.ControlName] = "MainWindow";
         }
         return _mainWindow.TryFind();
     }
    

    For more examples of how to use Coded UI to do various tasks, see my website codeduiexamples.com

提交回复
热议问题