2016-03-24 25 views
0

申し訳ありませんが外乱のために申し訳ありませんが、私はあなたの助けが必要です。 私はC#、Whiteフレームワークでは初心者です。c#白、ウィンドウで要素を見つけることができません

ここに問題があります... 私は非常に基本的なWinFormアプリケーションを自動化しようとしています。自動化のための

マニュアルの手順:

  1. オープンウィンドウ

  2. ファイルのダウンロードこのウィンドウに

  3. 、このウィンドウの下部にある

問題をキャプションを探す:I任意のボタンを押したり、ダイアログを開いたりすることができます。 しかし、いくつかの手順の後で私はラベル(キャプション)を見つけることができません。

私は2台のPCでこのコードを試しました。 1台のパソコンでは、他のパソコンでは動作しません。 このラベルが見つかったのは1回だけでした。

通常、Studioはハングアップして要素を検索しようとしています。

スタジオは非常に素早く動作し、要素は読み込めないと思います。これで私を助けてくれますか?代わりにmainWindowをリロードのあなただけのプロセスを再度再接続したい場合、どのようenter image description here

 //Add file name for opening 
     TextBox listLoadFile = mainWindow.Get<TextBox>(SearchCriteria.ByText("File name:")); 
     listLoadFile.Text = "Omneon_72.lst"; 
     application.WaitWhileBusy(); 

     // open file 
     Keyboard.Instance.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN); 
     application.WaitWhileBusy(); 

     mainWindow.Focus(); 
     mainWindow.ReloadIfCached(); 

     //Can't find this element 
     Label caption3 = mainWindow.Get<Label>(SearchCriteria.ByAutomationId("lblStatus")); 

     //Can't see elements 
     IUIItem[] children1 = mainWindow.GetMultiple(SearchCriteria.All); 

答えて

0

process = Process.GetProcessesByName("myProcess")[0]; 
    application = Application.Attach(process.Id); 
    mainWindow = application.GetWindow("myWindowTitle"); 

    Label caption3 = mainWindow.Get<Label>(SearchCriteria.ByAutomationId("lblStatus")); 
    IUIItem[] children1 = mainWindow.GetMultiple(SearchCriteria.All); 
関連する問題