Example #1
0
        public void AutoClickStart()
        {
            try
            {
                Application app = FlaUI.Core.Application.Attach(Process.GetProcessById(RemotePlayProcess.Id));

                using (var automation = new UIA2Automation())
                {
                    while (true)
                    {
                        Window window  = app.GetMainWindow(automation);
                        Button button1 = window.FindFirstDescendant(cf => cf.ByText("Start"))?.AsButton();
                        if (button1 == null)
                        {
                            Thread.Sleep(1000);
                        }

                        else
                        {
                            button1?.Invoke();
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Logger.Error("Problem with auto-clicker: " + ex.Message);
            }
        }
Example #2
0
 internal void SetFlaUIWindow()
 {
     using (var automation = new FlaUI.UIA3.UIA3Automation())
     {
         var app = FlaUI.Core.Application.Attach(PID);
         _FlaUIWindow = app.GetMainWindow(automation);
         //UIElement = new UIElement(this, _FlaUIWindow);
     }
 }
Example #3
0
        public static void AssertLoadAasx(Application application, Window mainWindow, string path)
        {
            if (!File.Exists(path))
            {
                throw new InvalidOperationException($"The AASX file to be loaded does not exist: {path}");
            }

            var fileMenuItem = mainWindow
                               .FindFirstDescendant(
                cf => cf.ByClassName("MenuItem").And(cf.ByName("File")))
                               .AsMenuItem();

            fileMenuItem.Click();

            var openMenuItem = fileMenuItem
                               .FindFirstChild(cf => cf.ByName("Open .."))
                               .AsMenuItem();

            if (openMenuItem == null)
            {
                throw new AssertionException(
                          "The open menu item is null. You need to thoroughly inspect what happened -- " +
                          "this is quite strange.");
            }

            openMenuItem.Click();

            Retry.WhileEmpty(
                () => mainWindow.ModalWindows,
                throwOnTimeout: true, timeout: TimeSpan.FromSeconds(10),
                timeoutMessage: "Could not find the modal windows of the main window");

            Assert.AreEqual(1, mainWindow.ModalWindows.Length);

            var modal     = mainWindow.ModalWindows[0];
            var pathCombo = modal.FindFirstChild(cf => cf.ByAutomationId("1148")).AsComboBox();

            pathCombo.EditableText = path;

            var openButton = modal.FindFirstChild(cf => cf.ByAutomationId("1")).AsButton();

            openButton.Click();

            Assert.IsEmpty(modal.ModalWindows,
                           $"Unexpected modal window (probably an error) while opening the AASX: {path}");

            Retry.WhileTrue(() => mainWindow.ModalWindows.Length > 0,
                            throwOnTimeout: true, timeout: TimeSpan.FromSeconds(10));

            if (application.HasExited)
            {
                throw new AssertionException(
                          "The application unexpectedly exited. " +
                          $"Check manually why the file could not be opened: {path}");
            }
        }
        public static void ChameleonUnitTestInit(TestContext context)
        {
            ChameleonApplication = Application.Launch("..\\..\\..\\..\\ChameleonMiniGUI\\bin\\Debug\\ChameleonMiniGUI.exe");

            using (var automation = new UIA3Automation())
            {
                MainWindow = ChameleonApplication.GetMainWindow(automation);
                Assert.IsNotNull(MainWindow);

                while (MainWindow.Title == "SplashScreen")
                {
                    Thread.Sleep(1000);
                    MainWindow = ChameleonApplication.GetMainWindow(automation);
                }
            }
        }
Example #5
0
        /// <summary>
        /// Retry until the label element with number of errors is found and then check that there are no errors.
        ///
        /// If the search times out, an exception will be thrown.
        /// </summary>
        /// <param name="application">AASX Package Explorer application under test</param>
        /// <param name="mainWindow">Main window of <paramref name="application"/></param>
        /// <remarks>Both <paramref name="application"/> and <paramref name="mainWindow"/> should be obtained
        /// with <see cref="RunWithMainWindow"/></remarks>
        public static void AssertNoErrors(Application application, Window mainWindow)
        {
            const string automationId = "LabelNumberErrors";

            var numberErrors = Retry.Find(
                () => (application.HasExited) ? null : mainWindow.FindFirstChild(cf => cf.ByAutomationId(automationId)),
                new RetrySettings {
                ThrowOnTimeout = true, Timeout = TimeSpan.FromSeconds(5)
            });

            Assert.IsFalse(application.HasExited,
                           "Application unexpectedly exited while searching for number of errors label");

            Assert.IsNotNull(numberErrors, $"Element {automationId} could not be found.");

            Assert.AreEqual("Text", numberErrors.ClassName, $"Expected {automationId} to be a label");
            Assert.AreEqual("No errors", numberErrors.AsLabel().Text, "Expected no errors on startup");
        }