2016-08-31 13 views
0

CodedUIを使用してデスクトップアプリケーションを自動化しようとしています。解決策を私に提案してください。コード化ui:別のコントロールがコントロールをブロックしています

{"Another control is blocking the control. Please make the blocked control visible and retry the action. Additional Details: 
TechnologyName: 'MSAA' 
ClassName: 'WindowsForms10.BUTTON' 
ControlType: 'Window'\r\n"} 

コード:私はSearchButtonWindowが[検索の親として割り当てられていない、ことがわかります。コードから

WinWindow SearchButtonWindow = new WinWindow(); 
      SearchButtonWindow.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch); 
      SearchButtonWindow.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); 
      SearchButtonWindow.SearchProperties[WinWindow.PropertyNames.ControlType] = "Window"; 
      SearchButtonWindow.SearchProperties[WinWindow.PropertyNames.ControlName] = "cmdSearch"; 
      //SearchButtonWindow.WindowTitles.Contains("Ascend Retail Management Software"); 
      WinButton SearchButton = new WinButton(); 
      SearchButton.SearchConfigurations.Add(SearchConfiguration.AlwaysSearch); 
      SearchButton.SearchConfigurations.Add(SearchConfiguration.VisibleOnly); 

      SearchButton.SearchProperties[WinWindow.PropertyNames.ControlType] = "Button"; 
      SearchButton.SearchProperties[WinButton.PropertyNames.ControlName]= "cmdSearch"; 

      Mouse.Click(SearchButton); 
+0

Stack Overflowやその他のWebサイトで、他によく似た質問がいくつありますか? – AdrianHHH

+0

私はほとんどevrythingしようとしました。私は解決策を見つけることはありません、それらのすべては境界線を取得し、クリックして、KeyBoardでenterをクリックするような回避策です。しかし、私のアプリケーションの問題は、CodedUIは、同じコントロール名と同じ境界線を持つウィンドウとボタンを表示しています。私たちはMouse.Clickを使用してボタンをクリックすることができる方法はありますか? –

答えて

0

。ほとんどの時間階層は、コントロールを一意に識別するためにも必要です。

WinButton SearchButton =新しいWinButton(SearchButtonWindow);

また、CodedUIテストビルダーツールを使用してSearchButtonWindowの子コントロールをチェックします(ウィンドウが強調表示されたら、Builderウィンドウの右上にある矢印キーを使用します)。下矢印キーは、現在強調表示されているコントロールここで、兄弟に右矢印キーの移動など)

0

はDrawhighlight()メソッドを使用して試してみて、テストが正しい制御に

0

を強調しているかどうかを見つける私は過去にこのに数回実行しました。通常は、オブジェクトの上にクリックできない透明なオブジェクトや他の不可視のオブジェクトがある場合です。オブジェクトの位置にマウスを移動させてから、clickコマンドを呼び出すと、オブジェクトにアクセスできます。

Point? xyPoint = GetCenterPoint(SearchButton); 

if (xyPoint != null) 
{ 
    Mouse.Click((Point)xyPoint); 
} 


public Point? GetCenterPoint(UITestControl objTarget) 
{ 
    Point? _Point = null; 
    try 
    { 
     if (objTarget != null && objTarget.GetProperty(UITestControl.PropertyNames.BoundingRectangle) != null) 
     { 
      double _CenterX = objTarget.BoundingRectangle.X + (objTarget.BoundingRectangle.Width/2); 
      int _PointX = Convert.ToInt32(_CenterX); 
      double _CenterY = objTarget.BoundingRectangle.Y + (objTarget.BoundingRectangle.Height/2); 
      int _PointY = Convert.ToInt32(_CenterY); 
      _Point = new Point(_PointX, _PointY); 
     } 
    } 
    catch (Exception ex) 
    { 
     //Exception Logging Here 
    } 
    return _Point; 
} 
関連する問題