public void TestMethod1() { var main = new WindowControl(mainCore); var CurrentText = new WPFTextBlock(mainCore.CurrentText); //各ボタンの初期状態を確認 Assert.AreEqual(true, _startButton.IsEnabled); Assert.AreEqual(false, _stopButton.IsEnabled); Assert.AreEqual(false, _resetButton.IsEnabled); Assert.AreEqual(false, _lapButton.IsEnabled); //ストップウォッチ画面の初期表示 Assert.AreEqual(CurrentText.Text, "00:00:00:00"); //ストップウォッチ起動(非同期)~停止まで var async = new Async(); _startButton.EmulateClick(async); Thread.Sleep(1000); _stopButton.EmulateClick(); async.WaitForCompletion(); //ストップウォッチ画面が更新されているか Assert.AreNotEqual(CurrentText.Text, "00:00:00:00"); }
public void RegisterFemaleSns() { Thread.Sleep(1000); dynamic window = _app.Type <Application>().Current.MainWindow; var nameTextBox = new WPFTextBox(window.Name); nameTextBox.EmulateChangeText("Peach"); Thread.Sleep(1000); var sexRadio = new WPFButtonBase(window.Female); sexRadio.EmulateClick(); Thread.Sleep(1000); var reasonComboBox = new WPFComboBox(window.Reason); reasonComboBox.EmulateChangeSelectedIndex(2); Thread.Sleep(1000); var registerBtn = new WPFButtonBase(window.RegisterBtn); registerBtn.EmulateClick(); var outputTxtBlock = new WPFTextBlock(window.Output); Assert.AreEqual(outputTxtBlock.Text.Replace("\n", ""), $"登録者名: Peach\n性別: 女性\n登録する経緯: SNSで見た".Replace("\n", "")); Thread.Sleep(1000); }
public void TestText() { WPFTextBlock textBox = new WPFTextBlock(Target); textBox.Dynamic().Text = TestValue; string textBoxText = textBox.Text; Assert.AreEqual(TestValue, textBoxText); }
/// <summary> /// /// </summary> /// <param name="window"></param> public MainWindowDriver(dynamic window) { var w = new WindowControl(window); this.Lhs = new WPFTextBox(w.LogicalTree().ByBinding("Lhs").Single()); this.Rhs = new WPFTextBox(w.LogicalTree().ByBinding("Rhs").Single()); this.OperatorType = new WPFComboBox(w.LogicalTree().ByBinding("OperatorTypes").Single()); this.Execute = new WPFButtonBase(w.LogicalTree().ByBinding("ExecuteCommand").Single()); this.Answer = new WPFTextBlock(w.LogicalTree().ByBinding("Answer").Single()); }
public void コントロール特定3() { WindowsAppExpander.LoadAssembly(_app, GetType().Assembly); WPFStandardControls_3_5.Injection(_app); AppVar main = _app.Type <Application>().Current.MainWindow; var userControl = main.LogicalTree().ByType("WpfApplication.DemoSimpleControl").Single(); var elements = _app.Type(GetType()).GetDemoSimpleControlElements(userControl); var textBlokX = new WPFTextBlock(elements.TextBlockXName); var textBlokMail = new WPFTextBlock(elements.TextBlockMail); var textBlokxLanguage = new WPFTextBlock(elements.TextBlockLanguage); var textBoxX = new WPFTextBox(elements.TextBoxXName); var textBoxMail = new WPFTextBox(elements.TextBoxMail); var comboBoxxLanguage = new WPFComboBox(elements.ComboBoxLanguage); var buttonOpen = new WPFButtonBase(elements.ButtonOpen); var button1 = new WPFButtonBase(elements.Button1); var buttonA = new WPFButtonBase(elements.ButtonA); var buttonCancel = new WPFButtonBase(elements.ButtonCancel); }
public WPFControls(WindowControl rootControl) { textBox = new WPFTextBox(rootControl.IdentifyFromLogicalTreeIndex(0, 4, 3, 5, 3, 0, 2)); phraseField = new WPFTextBox(rootControl.GetFromTypeFullName("AI.Talk.Editor.PhraseEditView").Single().LogicalTree().ByType <TextBox>().Single()); statusBarItem = new WPFTextBlock(rootControl.IdentifyFromVisualTreeIndex(0, 0, 0, 0, 2, 0, 0, 0, 4, 0, 0, 0)); }
public void WPF() { var app = new WindowsAppFriend(Process.Start("Wpf.exe")); var window = app.Type().System.Windows.Application.Current.MainWindow; //ガタガタ言わずにx:Name使えばいいじゃん。 var _textBox = new WPFTextBox(window._textBox); _textBox.EmulateChangeText("x:Name最高!"); //嫌って言う人いるから頑張ったよ。 AppVar windowAppVar = window; var logicalTree = windowAppVar.LogicalTree(); var textBox = new WPFTextBox(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBox>().Single()); var textBlock = new WPFTextBlock(logicalTree.ByBinding("Memo").ByType<System.Windows.Controls.TextBlock>().Single()); var buttonModal = new WPFButtonBase(logicalTree.ByBinding("CommandModal").Single()); var buttonModalSequential = new WPFButtonBase(logicalTree.ByBinding("CommandModalSequential").Single()); var buttonModeless = new WPFButtonBase(logicalTree.ByBinding("CommandModeless").Single()); var listBox = new WPFListBox(logicalTree.ByBinding("Persons").Single()); //VisualTreeにしか現れない要素は気を付けて var item = listBox.GetItem(20); var itemText = new WPFTextBlock(item.VisualTree().ByBinding("Name").Single()); //これでもダメな場合は工夫してね! Process.GetProcessById(app.ProcessId).Kill(); }
public async Task Save(string msg, string fileName) { await Task.Run(async() => { try { //フォーカスしないようにする //ShowWindow(mainWindowHandle.ToInt32(), SW_HIDE); await Task.Delay(100); //再生完了待機 while (!saveButton.IsEnabled) { Console.WriteLine("saveBtn is not enabled"); await Task.Delay(100); } talkTextBox.EmulateChangeText(msg); var async = new Async(); saveButton.EmulateClick(async); //名前を付けて保存ダイアログ var saveFileWindow = uiTreeTop.WaitForNextModal(); var saveFileDialog = new NativeMessageBox(saveFileWindow); //ファイル名を入力 //右上の検索欄にも入力されてしまうが無視 var edits = saveFileDialog.Window.GetFromWindowClass("Edit"); foreach (var t in edits) { var edit = new NativeEdit(t); edit.EmulateChangeText(fileName); } saveFileDialog.EmulateButtonClick("保存(&S)"); //saveFileWindow.WaitForDestroy(); //出力状況を表示するダイアログの表示を待つ Console.WriteLine("waiting for showing progress window"); var progressWindow = uiTreeTop.WaitForNextModal(); if (progressWindow == null) { progressWindow = uiTreeTop.WaitForNextModal(); } Console.WriteLine("showed " + progressWindow.GetWindowText()); var tokenSource = new CancellationTokenSource(); var task = new TaskFactory().StartNew(() => { //完了通知ダイアログの表示を待つ Console.WriteLine("wationg for showing saving complete window"); var completeWindow = progressWindow.WaitForNextModal(); if (completeWindow != null) { Console.WriteLine("showed " + completeWindow.GetWindowText()); Console.WriteLine(DateTime.Now); try { var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying"); completeWindow.WaitForDestroy(); Console.WriteLine("finish"); } catch (Exception e) { Console.WriteLine(e); } } }, tokenSource.Token); try { Console.WriteLine(DateTime.Now); if (!task.Wait(5000)) { tokenSource.Cancel(); Console.WriteLine("timeout"); Console.WriteLine(DateTime.Now); var windows = WindowControl.GetTopLevelWindows(uiTreeTop.App); foreach (var window in windows) { Console.WriteLine(window.GetWindowText()); var btnList = window.LogicalTree().ByType <Button>(); var count = btnList.Count; for (int i = 0; i < count; i++) { var btn = new WPFButtonBase(btnList[i]); var btnTxtList = btn.LogicalTree(TreeRunDirection.Descendants).ByType <TextBlock>(); if (btnTxtList.Count == 1) { var btnTxt = new WPFTextBlock(btnTxtList.Single()); Console.WriteLine(btnTxt.Text); if (btnTxt.Text.Equals("キャンセル")) { btn.EmulateClick(); } } } } var completeWindow = progressWindow.WaitForNextModal(); Console.WriteLine("showed2 " + completeWindow.GetWindowText()); Console.WriteLine("2" + DateTime.Now); var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying2"); completeWindow.WaitForDestroy(); Console.WriteLine("finish2"); } } catch (AggregateException) { //タスクがキャンセルされた Console.WriteLine("task was canceled"); var completeWindow = WindowControl.FromZTop(uiTreeTop.App); Console.WriteLine("showed3 " + completeWindow.GetWindowText()); var completeDialog = new NativeMessageBox(completeWindow); completeDialog.EmulateButtonClick("OK"); Console.WriteLine("wating for destroying3"); completeWindow.WaitForDestroy(); Console.WriteLine("finish3"); } if (!async.IsCompleted) { try { Console.WriteLine("wating for async finish"); async.WaitForCompletion(); } catch (Exception e) { Console.WriteLine(e); } } } finally { //ShowWindow(mainWindowHandle.ToInt32(), SW_MINIMIZE); Console.WriteLine("complete saving"); } }); }
void Assert(string accessPath, WPFTextBlock textBlock) => CaptureAdaptor.AddCode($"{accessPath}.Text.Is({ToLiteral(textBlock.Text)});");