понедельник, 9 июня 2014 г.

Coded UI Tests.Work with process

[ClassCleanup] public static void ClassCleanup() { // Close the app after all tests are finished Playback.Initialize(); try { Process[] processes = Process.GetProcessesByName(testProcess); foreach (Process process in processes) { ApplicationUnderTest app = ApplicationUnderTest.FromProcess(process); app.Close(); } } finally { Playback.Cleanup(); } }

[TestInitialize()] public void TestInitialize() { // Launch Calculator if not already running if (Process.GetProcessesByName(testProcess).Length == 0) { //TODO: do not hard code paths testApp = ApplicationUnderTest.Launch(@"C:\Windows\system32\" + testProcess + ".exe"); } }


[TestMethod] public void FromProcess_FindAllBrowserWindows_CanGetUriAndTitle() { Process[] processes = Process.GetProcessesByName("iexplore"); foreach (Process process in processes) { if (string.IsNullOrEmpty(process.MainWindowTitle)) { continue; } BrowserWindow bWin = CUITe_BrowserWindow.FromProcess(process); Trace.WriteLine(string.Format("Found browser window: {0} {1}", bWin.Uri, bWin.Title)); } }

Комментариев нет:

Отправить комментарий