public Application(string packageName, string packageFamilyName, string appName, string testAppMainWindowTitle, string testAppProcessName, string testAppInstallerName, string certSerialNumber, string baseAppxDir, bool isUWPApp, string unpackagedExePath, bool isPackaged) { _packageName = packageName; _packageFamilyName = packageFamilyName; _appName = appName; _isUWPApp = isUWPApp; _isPackaged = isPackaged; _unpackagedExePath = unpackagedExePath; _certSerialNumber = certSerialNumber; _baseAppxDir = baseAppxDir; _appWindowTitle = testAppMainWindowTitle; _appProcessName = testAppProcessName; _appInstallerName = testAppInstallerName; if (_isUWPApp && _isPackaged) { _windowCondition = UICondition.Create("@ClassName='Windows.UI.Core.CoreWindow' AND @Name={0}", _appWindowTitle); _appFrameWindowCondition = UICondition.Create("@ClassName='ApplicationFrameWindow' AND @Name={0}", _appWindowTitle); } else { _windowCondition = UICondition.Create("@ClassName='Window' AND @Name={0}", _appWindowTitle); _appFrameWindowCondition = UICondition.Create("@ClassName='Window' AND @Name={0}", _appWindowTitle); } }
public void Test_Piano(MouseButtons key) { UICondition uICoPiano = UICondition.Create("@Name='Volume'and @ControlType=Pane", new Object[0]); UIObject uIPiano = this.uImain.Children.Find(uICoPiano); for (int i = 10; i < 60; i = i + 20) { Mouse.Instance.Click(key, uIPiano, i, 50, ModifierKeys.None); Thread.Sleep(2000); switch (i) { case 70: Mouse.Instance.Click(key, uIPiano, i + 10, 20, ModifierKeys.None); Thread.Sleep(2000); break; case 130: Mouse.Instance.Click(key, uIPiano, i + 10, 20, ModifierKeys.None); Thread.Sleep(2000); break; case 190: Mouse.Instance.Click(key, uIPiano, i + 10, 20, ModifierKeys.None); Thread.Sleep(2000); break; case 250: Mouse.Instance.Click(key, uIPiano, i + 10, 20, ModifierKeys.None); Thread.Sleep(2000); break; } } }
public void Test_ADDCarrierModulator() { UICondition uIconAddCa = UICondition.Create("@Name='Add Carrier'", new Object[0]); UICondition uIconAddMo = UICondition.Create("@Name='Add Modulator'", new Object[0]); Random rand = new Random(System.Environment.TickCount); UIObject uIOAddCa = this.uImain.Children.Find(uIconAddCa); UIObject uIOAddMo = this.uImain.Children.Find(uIconAddMo); uIOAddCa.Click(); for (int i = 0; i < 25; i++) { int a = rand.Next(2); switch (a) { case 0: uIOAddCa.Click(); CarNum++; break; case 1: uIOAddMo.Click(); break; } } }
static void Main(string[] args) { UICondition uIcondition = UICondition.Create("@Name='Frequency Modulation Synthesizer'", new Object[0]); WindowOpenedWaiter wait1 = new WindowOpenedWaiter(uIcondition); //Process.Start(args[0], ".\\fmsynth.py"); Process.Start(args[0], ".\\fmsynth.py"); wait1.Wait(60000); UIObject ui = UIObject.Root.Children.Find(uIcondition); try { WinClass winClass = new WinClass(ui); winClass.Test_ADDCarrierModulator(); winClass.Test_RemoveSource(); winClass.Test_Button_rightpane(); winClass.Test_ComboBox(); winClass.Test_Scrollbar(); winClass.Test_Piano(MouseButtons.PhysicalLeft); winClass.Test_Stop(); winClass.Test_Piano(MouseButtons.PhysicalRight); winClass.Test_StopAll(); winClass.Test_Close(); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void play_puzzle() { int i; UICollection <UIObject> UICoPane; UICondition uIpane = UICondition.Create("@ControlType=Pane", new Object[0]); UIObject uIopane = this.Children.Find(uIpane); //UICondition uIpane = UICondition.Create("@ControlType=ControlType.Pane", new Object[0]); UICoPane = uIopane.Children.FindMultiple(uIpane); int Dim = UICoPane.Count; //foreach (UIObject i in UICoPane) //{ // Window objpuzzle = new Window(i); // objpuzzle.Click(); //} for (int aa = 0; aa < 40; aa++) { Random rand = new Random(Environment.TickCount); i = rand.Next(Dim); //Console.Write(i.ToString()+" : "); //Console.WriteLine(UICoPane.Count.ToString()+" : "+aa.ToString()); Window objpuzzle = new Window(UICoPane[i]); objpuzzle.Click(); Thread.Sleep(200); } }
private bool CloseAppWindowWithCloseButton() { var topWindowCondition = _windowCondition.OrWith(_appFrameWindowCondition); UIObject topWindowObj = null; bool didFindWindow = UIObject.Root.Children.TryFind(topWindowCondition, out topWindowObj); if (!didFindWindow) { Log.Comment("Application.CloseAppWindowWithCloseButton: Cound not find app window."); return(false); } Log.Comment("Closing application: {0}", topWindowObj); UIObject closeAppInvoker; if (!topWindowObj.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out closeAppInvoker)) { Log.Comment("Application.CloseAppWindowWithCloseButton: Failed to find close app invoker."); return(false); } Log.Comment("Invoking CloseAppInvoker {0}", closeAppInvoker); (new Button(closeAppInvoker)).Invoke(); bool didWindowClose = WaitForWindowToClose(topWindowCondition); if (!didWindowClose) { Log.Comment("Application.CloseAppWindowWithCloseButton: Window did not close"); return(false); } return(true); }
static void Main(string[] args) { UICondition uIcondition = UICondition.Create("@Name='Puzzle'", new Object[0]); WindowOpenedWaiter wait = new WindowOpenedWaiter(uIcondition); var ipy_proc = Process.Start(System.Environment.GetEnvironmentVariable("DLR_BIN") + "\\ipy.exe", " .\\puzzle.py"); wait.Wait(30000); UIObject ui = UIObject.Root.Children.Find(uIcondition); WinClass winClass = new WinClass(ui); try { winClass.Test_about(); winClass.Test_options(); winClass.Test_load(); //http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25404 // winClass.Test_play(); //exit verification winClass.Test_create(); //http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25404 //winClass.Test_play(); winClass.Test_exit(); } catch (Exception e) { Console.WriteLine(e); } finally { //http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=19693 if (!ipy_proc.HasExited) { ipy_proc.Kill(); } } }
public void Test_StopAll() { UICondition uICoStopAll = UICondition.Create("@Name='Stop All'", new Object[0]); UIObject uIStopAll = this.uImain.Children.Find(uICoStopAll); Button button = new Button(uIStopAll); button.Click(); }
public static IEnumerable <UIObject> GetTopLevelWindowsClassicApp( int processId) { UICollection.Timeout = TimeSpan.Zero; foreach (var uiObject in UIObject.Root.Children.FindMultiple(condition: UICondition.Create(property: UIProperty.Get(name: "ProcessId"), value: processId).AndWith(newCondition: UICondition.Create(property: UIProperty.Get(name: "ControlType"), value: ControlType.Window)))) { yield return(uiObject); } }
public void Test_Button_rightpane() { UICondition uICoUseRatio = UICondition.Create("@Name='Use ratio'", new Object[0]); UIObject uIOUseRatio = this.uImain.Children.Find(uICoUseRatio); CheckBox cbox = new CheckBox(uIOUseRatio); Thread.Sleep(400); cbox.Click(); }
public void Test_about() { UICondition uICondition = UICondition.Create("@Name='about'", new Object[0]); UIObject uIObject = this.Descendants.Find(uICondition); Window obj = new Window(uIObject); UICondition uICondition2 = UICondition.Create("@Name='Tile Size'", new Object[0]); obj.Click(); Thread.Sleep(300); UIObject result = this.Children.Find(uICondition2); }
public void Test_Scrollbar() { UICondition uICoScro = UICondition.Create("@Name='Amplitude'and @ControlType=ScrollBar", new Object[0]); UIObject uIScor = this.uImain.Children.Find(uICoScro); ScrollBar scrollBar = new ScrollBar(uIScor); Button button = new Button(scrollBar.Children.Find(UICondition.Create("@Name='Page left'", new Object[0]))); for (int i = 1; i < 7; i++) { button.Click(); } }
public void Test_RemoveSource() { UICondition uICoRem = UICondition.Create("@Name='Remove Source'", new Object[0]); UIObject uIRem = this.uImain.Children.Find(uICoRem); Button button = new Button(uIRem); while (this.CarNum > 2) { button.Click(); this.CarNum--; } }
public void Close() { if (Process != null) { Process.Dispose(); Process = null; } var topWindowCondition = _windowCondition.OrWith(_appFrameWindowCondition); UIObject topWindowObj = null; bool didFindWindow = UIObject.Root.Children.TryFind(topWindowCondition, out topWindowObj); if (didFindWindow) { Log.Comment("Closing application: {0}", topWindowObj); UIObject closeAppInvoker; if (topWindowObj.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out closeAppInvoker)) { (new Button(closeAppInvoker)).Invoke(); } else { Log.Comment("Application.Close: Failed to find close app invoker: {0}", closeAppInvoker); TestEnvironment.LogDumpTree(UIObject.Root); } // We'll wait until the window closes. For some reason, ProcessClosedWaiter // doesn't seem to actually work, so we'll instead just check for the window // until the check fails. int triesLeft = 20; do { if (triesLeft == 0) { throw new Exception("Application won't close!"); } Wait.ForMilliseconds(100); didFindWindow = UIObject.Root.Children.TryFind(topWindowCondition, out topWindowObj); triesLeft--; } while (didFindWindow); } else { Log.Comment("Could not find application CoreWindow. Has it already closed?"); } }
public void Test_Tutorial() { //checkpoint1 UICondition uIcondition = UICondition.Create("@ControlType=Window and @Name='IronPython Direct3D'", new object[0]); WindowOpenedWaiter wait1 = new WindowOpenedWaiter(uIcondition); Process.Start(CMD, ".\\tutorial.py"); wait1.Wait(20000); UIObject ui = UIObject.Root.Children.Find(uIcondition); UIObject uiClose = ui.FirstChild.Children.Find("Close"); Button buttonClose = new Button(uiClose); Thread.Sleep(5000); buttonClose.Click(); }
public void Test_ComboBox() { UICondition uICoComboBox = UICondition.Create("@ControlType=ComboBox and @Name=':1'", new Object[0]); UIObject uIComboBox = this.uImain.Children.Find(uICoComboBox); ComboBox combox = new ComboBox(uIComboBox); Thread.Sleep(400); ListBox lbox = new ListBox(combox.FirstChild); for (int i = 1; i < 3; i++) { combox.Expand(); lbox.Children[i].Click(); Thread.Sleep(400); } }
private UIObject Launch(string deploymentDir) { UIObject coreWindow = null; if (_isPackaged) { // When running from MUXControls repo we want to install the app. // When running in TestMD we also want to install the app. #if USING_TAEF TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFamilyName, _appInstallerName); #else InstallTestAppIfNeeded(); #endif } Log.Comment("Launching app {0}", _appName); coreWindow = LaunchApp(); Verify.IsNotNull(coreWindow, "coreWindow"); Log.Comment("Waiting for the close-app invoker to be found to signal that the app has launched successfully..."); for (int retries = 0; retries < 5; ++retries) { UIObject obj; coreWindow.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out obj); if (obj != null) { Log.Comment("Invoker found!"); break; } Log.Comment("Invoker not found. Sleeping for 500 ms before trying again..."); Thread.Sleep(500); } var unhandledExceptionReportingTextBox = new Edit(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__UnhandledExceptionReportingTextBox'"))); var valueChangedSource = new PropertyChangedEventSource(unhandledExceptionReportingTextBox, Scope.Element, UIProperty.Get("Value.Value")); valueChangedSource.Start(new TestAppCrashDetector()); Log.Comment("15056441 tracing, device family:" + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily); return(coreWindow); }
public Application(string packageName, string packageFullName, string appName, bool isUWPApp = true) { _packageName = packageName; _packageFullName = packageFullName; _appName = appName; _isUWPApp = isUWPApp; if (_isUWPApp) { _windowCondition = UICondition.Create("@ClassName='Windows.UI.Core.CoreWindow' AND @Name={0}", _packageName); _appFrameWindowCondition = UICondition.Create("@ClassName='ApplicationFrameWindow' AND @Name={0}", _packageName); } else { _windowCondition = UICondition.Create("@ClassName='Window' AND @Name={0}", _packageName); _appFrameWindowCondition = UICondition.Create("@ClassName='Window' AND @Name={0}", _packageName); } }
public void Test_play() { UICondition uIToStart = UICondition.Create("@Name='Shuffle\nto\nStart'", new Object[0]); for (int i = 0; i < 1000; i++) { if (this.Descendants.Contains(uIToStart)) { break; } Thread.Sleep(100); } UIObject uIoStart = this.Descendants.Find(uIToStart); Window objStart = new Window(uIoStart); objStart.Click(); play_puzzle(); }
public void Test_load() { UICondition uICondition = UICondition.Create("@Name='load'", new Object[0]); UIObject uIObject = this.Descendants.Find(uICondition); Window obj = new Window(uIObject); obj.Click(); UICondition uIButton1 = UICondition.Create("@Name='Seattle (default game)\n(327, 714)\nAerial - Zoom Level 11 - 3x3'", new Object[0]); UIObject uIoButton1 = this.Descendants.Find(uIButton1); Window objButton1 = new Window(uIoButton1); objButton1.Click(); Thread.Sleep(100); UICondition uIButton2 = UICondition.Create("@Name='New York\n(1205, 1538)\nRoad - Zoom Level 12 - 3x3'", new Object[0]); UIObject uIoButton2 = this.Descendants.Find(uIButton2); Window objButton2 = new Window(uIoButton2); objButton2.Click(); Thread.Sleep(100); UICondition uIButton3 = UICondition.Create("@Name='World\n(0, 0)\nHybrid - Zoom Level 2 - 4x4'", new Object[0]); UIObject uIoButton3 = this.Descendants.Find(uIButton3); Window objButton3 = new Window(uIoButton3); objButton3.Click(); Thread.Sleep(100); UICondition uIButton4 = UICondition.Create("@Name='North America\n(2, 5)\nAerial - Zoom Level 4 - 3x3'", new Object[0]); UIObject uIoButton4 = this.Descendants.Find(uIButton4); Window objButton4 = new Window(uIoButton4); objButton4.Click(); Thread.Sleep(100); UICondition uILoad = UICondition.Create("@Name='Load Puzzle'", new Object[0]); UIObject uIoLoad = this.Descendants.Find(uILoad); Window objLoad = new Window(uIoLoad); objLoad.Click(); }
public void Test_exit() { UICondition uICexit = UICondition.Create("@Name='exit'", new Object[0]); UIObject uIoExit = this.Descendants.Find(uICexit); Window objexit = new Window(uIoExit); //http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27142 //UIProperty u = UIProperty.Get("ClassName"); //UICondition uIcondition2 = UICondition.Create(u,"#32770"); //WindowOpenedWaiter wait2 = new WindowOpenedWaiter(uIcondition2); //objexit.Click(); //wait2.Wait(5000); //UIObject ui2 = this.Children.Find(uIcondition2); //UIObject uiyes = ui2.Children.Find(UICondition.Create("@Name='Yes'", new Object[0])); //Window winyes = new Window(uiyes); //Thread.Sleep(1000); //winyes.Click(); }
public void Test_options() { UICondition uICondition = UICondition.Create("@Name='options'", new Object[0]); UIObject uIObject = this.Descendants.Find(uICondition); Window obj = new Window(uIObject); UICondition uI2 = UICondition.Create("@Name='Tile Size'", new Object[0]); UICondition uI50 = UICondition.Create("@Name='50%'", new Object[0]); UICondition uI100 = UICondition.Create("@Name='100%'", new Object[0]); UICondition uI75 = UICondition.Create("@Name='75%'", new Object[0]); obj.Click(); UIObject uITileSize = this.Descendants.Find(uI2); UIObject uIo75 = this.Descendants.Find(uI75); UIObject uIo100 = this.Descendants.Find(uI100); Window obj75 = new Window(uIo75); obj75.Click(); Thread.Sleep(200); Window obj100 = new Window(uIo100); obj100.Click(); UIObject uIo50 = this.Descendants.Find(uI50); Thread.Sleep(200); Window obj50 = new Window(uIo50); obj50.Click(); Thread.Sleep(200); //UICondition uICache = UICondition.Create("@Name='Allow caching'", new Object[0]); //UIObject uIoCache = this.Descendants.Find(uICache); //Window objCache = new Window(uIoCache); //objCache.Click(); //Thread.Sleep(200); UICondition uIClsCa = UICondition.Create("@Name='Clear Cache'", new Object[0]); UIObject uIoClsCa = this.Descendants.Find(uIClsCa); Window objClsCa = new Window(uIoClsCa); objClsCa.Click(); Thread.Sleep(200); }
public void Test_create() { UICondition uICcreate = UICondition.Create("@Name='create'", new Object[0]); UIObject uIoCreate = this.Descendants.Find(uICcreate); Window objcreate = new Window(uIoCreate); objcreate.Click(); UICondition uI3x3 = UICondition.Create("@Name='3x3'", new Object[0]); UIObject uIo3x3 = this.Descendants.Find(uI3x3); UICondition uI4x4 = UICondition.Create("@Name='4x4'", new Object[0]); UIObject uIo4x4 = this.Descendants.Find(uI4x4); MS.Internal.Mita.Foundation.Controls.RadioButton radioButton3 = new MS.Internal.Mita.Foundation.Controls.RadioButton(uIo3x3); MS.Internal.Mita.Foundation.Controls.RadioButton radioButton4 = new MS.Internal.Mita.Foundation.Controls.RadioButton(uIo4x4); if (radioButton3.IsSelected) { radioButton4.Select(); } //http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27142 //UICondition uICcreate2 = UICondition.Create("@Name='Create'", new Object[0]); //UIObject uIoCreate2 = this.Descendants.Find(uICcreate2); //Window objcreate2 = new Window(uIoCreate2); //UIProperty u = UIProperty.Get("ClassName"); //UICondition uIcondition2 = UICondition.Create(u, "#32770"); //WindowOpenedWaiter wait2 = new WindowOpenedWaiter(uIcondition2); //objcreate2.Click(); //wait2.Wait(5000); //UIObject ui2 = this.Children.Find(uIcondition2); //UIObject uiyes = ui2.Children.Find(UICondition.Create("@Name='Yes'", new Object[0])); //Window winyes = new Window(uiyes); //Thread.Sleep(300); //winyes.Click(); }
public MenuOpenedWaiter(UIProperty uiProperty, object value) : this(condition : UICondition.Create(property : uiProperty, value : value)) { }
private UIObject Launch(string deploymentDir) { UIObject coreWindow = null; // When running from MUXControls repo we want to install the app. // When running in TestMD we also want to install the app. // In CatGates, we install the test app as part of the deploy script, so we don't need to do anything here. #if BUILD_WINDOWS if (TestEnvironment.TestContext.Properties.Contains("RunFromTestMD")) { TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFullName); } #elif USING_TAEF TestAppInstallHelper.InstallTestAppIfNeeded(deploymentDir, _packageName, _packageFullName); #else BuildAndInstallTestAppIfNeeded(); #endif Log.Comment("Launching app {0}", _appName); coreWindow = LaunchApp(_packageName); Verify.IsNotNull(coreWindow, "coreWindow"); Log.Comment("Waiting for the close-app invoker to be found to signal that the app has launched successfully..."); for (int retries = 0; retries < 5; ++retries) { UIObject obj; coreWindow.Descendants.TryFind(UICondition.Create("@AutomationId='__CloseAppInvoker'"), out obj); if (obj != null) { Log.Comment("Invoker found!"); break; } Log.Comment("Invoker not found. Sleeping for 500 ms before trying again..."); Thread.Sleep(500); } var unhandledExceptionReportingTextBox = new Edit(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__UnhandledExceptionReportingTextBox'"))); var valueChangedSource = new PropertyChangedEventSource(unhandledExceptionReportingTextBox, Scope.Element, UIProperty.Get("Value.Value")); valueChangedSource.Start(new TestAppCrashDetector()); Log.Comment("15056441 tracing, device family:" + Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily); // On phone, we work around different scale factors between devices by configuring the test app to // lay out the test pages at the device's resolution, effectively giving us a scale factor of 1.0. if (PlatformConfiguration.IsDevice(DeviceType.Phone)) { Log.Comment("Enabling view scaling workaround on phone."); try { var viewScalingCheckBox = new CheckBox(coreWindow.Descendants.Find(UICondition.Create("@AutomationId='__ViewScalingCheckBox'"))); using (var waiter = viewScalingCheckBox.GetToggledWaiter()) { viewScalingCheckBox.Check(); } Log.Comment("15056441 Tracing: New checkbox state is " + viewScalingCheckBox.ToggleState); } catch (UIObjectNotFoundException) { Log.Error("Could not find the view scaling CheckBox."); TestEnvironment.LogDumpTree(UIObject.Root); throw; } } return(coreWindow); }
public FocusAcquiredWaiter(UIProperty uiProperty, string value) : this(condition : UICondition.Create(property : uiProperty, value : value)) { }
public ToolTipOpenedWaiter(UIProperty uiProperty, string value) : this(condition : UICondition.Create(property : uiProperty, value : value)) { }
public ElementAddedWaiter(UIObject root, Scope scope, UIProperty uiProperty, object value) : this(root : root, scope : scope, condition : UICondition.Create(property : uiProperty, value : value)) { }