Beispiel #1
0
 //Default Constructor
 public AutoApp()
 {
     exeSourceFile = "";
     appName       = "";
     _application  = null;  //This is set by the start method
     _mainWindow   = null;  //This is set by the start method
 }
Beispiel #2
0
        public void startApp(string iappName)
        {
            try
            {
                //Get the appname
                if (iappName != "")
                {
                    appName = iappName;
                }
                else
                {
                    MessageBox.Show("Incorrect App Name");
                }

                var psi = new ProcessStartInfo(exeSourceFile);

                // launch the process through white application
                _application = TestStack.White.Application.AttachOrLaunch(psi);

                //Get the window of calculator from white application
                _mainWindow = _application.GetWindow(SearchCriteria.ByText(appName), InitializeOption.NoCache);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + " \n Failed to start App. App name may not be set!");
            }
        }
Beispiel #3
0
        public void setupapp()
        {
            string app_path = @"C:\Users\gasundar\Downloads\White-master\White-master\src\TestApplications\WpfTestApplication\bin\Debug\WpfTestApplication.exe";

            application = White.Application.Launch(app_path);
            Window mainWindow = application.GetWindow("MainWindow");
        }
Beispiel #4
0
        public void setupapp()
        {
            string app_path = "";//"Download WPFTestApplication from https://github.com/TestStack/White/tree/master/src/TestApplications/WpfTestApplication and paste the path to *exe* here"

            application = White.Application.Launch(app_path);
            Window mainWindow = application.GetWindow("MainWindow");
        }
Beispiel #5
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var psi = new ProcessStartInfo(System.Windows.Forms.Application.ExecutablePath);
            // launch the process through white application
            _application = TestStack.White.Application.Attach(Process.GetCurrentProcess());
            _mainWindow = _application.GetWindow("MainWindow", InitializeOption.NoCache);

            Point textboxLocation = txtbox.PointToScreen(new Point(0d, 0d));

            Microsoft.Test.Input.Mouse.MoveTo(new System.Drawing.Point((int)textboxLocation.X, (int)textboxLocation.Y));
            Microsoft.Test.Input.Mouse.Click(Microsoft.Test.Input.MouseButton.Left);

            TextCompositionManager.StartComposition(
                new TextComposition(InputManager.Current, txtbox, "pwpito"));

            //var button = _mainWindow.Get<Button>("stopButton");
            //button.Click();


            //TextCompositionManager.StartComposition(
            //    new TextComposition(InputManager.Current, txtbox, " papito"));

            //AutomationElement automationElement = _mainWindow.GetElement(SearchCriteria.ByAutomationId("stopButton"));
            //var invokePattern = automationElement.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern;
            //invokePattern.Invoke();

            //this.stopButton.

            //Keyboard.Type("Hello world.");
            //Keyboard.Press(Key.Shift);
            //Keyboard.Type("hello, capitalized world.");
            //Thread.Sleep(100);
            //SendKeys.SendWait("pepe");
            // Keyboard.Release(Key.Shift);
        }
Beispiel #6
0
        /// <summary>
        /// 启动客户端
        /// </summary>
        /// <param name="appWin">客户端</param>
        /// <param name="msg">测试结果</param>
        /// <param name="path">客户端路径</param>
        /// <param name="name">客户端名称</param>
        /// <param name="id">客户端id</param>
        /// <returns></returns>
        public static bool Launch(out Window appWin, out string msg, string path, string name, string id)
        {
            //启动客户端
            try
            {
                var startTime = DateTime.Now;
                TestStack.White.Application appTest = TestStack.White.Application.Launch(path);

                Thread.Sleep(2000);
                //如果会打开多个客户端,需要修改获取方式FirstOrDefault为Index,按照客户端的打开顺序来捕捉
                appWin = TestStack.White.Desktop.Instance.Windows().FirstOrDefault(l => l.Id == id);
                var endTime = DateTime.Now;
                msg = "启动" + name + "客户端--通过,用时:" + (endTime - startTime).TotalSeconds;

                //模拟鼠标单击任意点,关闭更新提醒


                return(true);
            }
            catch (Exception e)
            {
                appWin = null;
                msg    = "启动" + name + "客户端--失败,原因:" + e.ToString();
                return(false);
            }
        }
        public void setupapp()
        {
            string outputDir = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName;
            string app_path  = outputDir + @"\Microsoft.DAS.Client.Shell.exe";

            application = White.Application.Launch(app_path);
            Window mainWindow = application.GetWindow("MainWindow");
        }
 public IIdeaProcessManipulator Attach()
 {
     _mainWindow = Application.Attach("idea64")
                   .Find(title => title.Contains("IntelliJ IDEA"), InitializeOption.WithCache);
     _intPtr         = GetDC(IntPtr.Zero);
     _turnedOffPixel = GetPixel(_intPtr, (int)_extractButtonPosition.X, (int)_extractButtonPosition.Y);
     return(this);
 }
        private static Window SetUpWindow()
        {
            applicationDirectory = TestContext.CurrentContext.TestDirectory;
            applicationPath      = Path.Combine(applicationDirectory, "WinFormApp.exe");
            Application application = Application.Launch(applicationPath);
            Window      window      = application.GetWindow("Form1", InitializeOption.NoCache);

            return(window);
        }
Beispiel #10
0
 public void SetUp()
 {
     leraApp    = TestStack.White.Application.Launch("LeraForm.exe");
     mainWindow = leraApp.GetWindow("myWin");
     btn        =
         mainWindow.Get <TestStack.White.UIItems.Button>(SearchCriteria.ByAutomationId("button1"));
     label =
         mainWindow.Get <TestStack.White.UIItems.Label>(SearchCriteria.ByAutomationId("label1"));
 }
        public void OpenFlStudio()
        {
            TestStack.White.Application application = TestStack.White.Application.Launch(flStudioPath);
            this.window       = application.GetWindow("FL Studio 20", InitializeOption.NoCache);
            this.windowHandle = application.Process.Handle;
            Logger.Log($"Recived window Handle: {windowHandle}");

            UIItemCollection coll = window.Items;
        }
        internal void CloseApp()
        {
            mainWindow.Close();

            elements.Clear();
            activeWindow = null;
            mainWindow   = null;
            App          = null;
        }
Beispiel #13
0
        public void StartApplication()
        {
            string curPath = System.IO.Path.GetFullPath(System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, @"..\..\..\"));//D:\Bitbucket\Solution\eIModelTest\bin\Debug\TestResults\y.oleynik_IT060 2016-09-15 14_19_45\Out
            string path    = curPath + @"Global\bin\Debug\";

            System.Console.WriteLine(System.AppDomain.CurrentDomain.BaseDirectory);
            System.Console.WriteLine(path);
            Assert.AreEqual(path, @"Global\bin\Debug\");
            System.Diagnostics.ProcessStartInfo prc = new System.Diagnostics.ProcessStartInfo("Global.exe");
            prc.WorkingDirectory = path;
            TestStack.White.Application application = TestStack.White.Application.Launch(prc);
            Window window = application.GetWindow("Global", TestStack.White.Factory.InitializeOption.NoCache);
            //D:\Dev\Git\Logger\LoggerTest\bin\Debug // TestLoggerConsole\bin\Debug */
        }
Beispiel #14
0
        //This method execute psc application, Only need to execute once
        public static Application launchPSC()
        {
            //Variable to open the test
            var psi = new System.Diagnostics.ProcessStartInfo
            {
                FileName  = "iexplore.exe",
                Arguments = "https://wsx0038pa.theranos.local/QA.PSC.App/PSC.QA.application"
            };

            application = TestStack.White.Application.Launch(psi);
            Console.WriteLine("******************** Wait for 30 seconds for PSC to start ********************");
            Thread.Sleep(15000);
            return(application);
        }
 private void Fill()
 {
     WindowTreeview.Items.Clear();
     if (!string.IsNullOrEmpty(PathTextBox.Text))
     {
         _app = Application.AttachOrLaunch(new ProcessStartInfo(PathTextBox.Text));
         var elementList = new List<Element>();
         var index = 0;
         foreach (Window window in _app.GetWindows())
         {
             WindowTreeview.Items.Add(CreateTreeItem(window, index));
         }
     }
 }
 /// <summary>
 /// Same as WaitWhileBusy, but doesn't throw when the application exits; it returns instead.
 /// </summary>
 public static void WaitWhileBusyAndAlive(this TestStack.White.Application app)
 {
     try
     {
         app.WaitWhileBusy();
     }
     catch (InvalidOperationException)
     {
         if (!app.HasExited)
         {
             throw;
         }
     }
 }
        private TreeNode ShowWindow()
        {
            treeView.Nodes.Clear();

            List <Window> windows = WindowFactory.Desktop.DesktopWindows();

            System.Diagnostics.ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
            si.FileName = @"C:\Windows\explorer.exe";
            TestStack.White.Application appExplorer = TestStack.White.Application.AttachOrLaunch(si);
            System.Diagnostics.Process  appCurrent  = System.Diagnostics.Process.GetCurrentProcess();

            TreeNode matchedWindowNode = null;

            foreach (Window window in windows)
            {
                if (window.IsOffScreen || !window.Visible || window.Name.Length == 0)
                {
                    continue;
                }

                if (window.AutomationElement.Current.ProcessId == appCurrent.Id)
                {
                    continue;
                }

                if (window.Title == @"Program Manager" && window.AutomationElement.Current.ProcessId == appExplorer.Process.Id)
                {
                    continue;
                }

                ControlTreeNode node = new ControlTreeNode(window.Name);
                node.Tag = window;
                node.Nodes.Add("");
                if (matchedWindowNode == null && CurrentInterface != null && ActionManager.MatchWindow(window, CurrentInterface.Properties))
                {
                    matchedWindowNode     = node;
                    node.ForeColor        = Color.Green;
                    node.NodeFont         = new Font(SystemFonts.DefaultFont, FontStyle.Bold);
                    node.Text             = node.Text;
                    node.MatchedName      = CurrentInterface.Name;
                    treeView.SelectedNode = node;
                }
                treeView.Nodes.Add(node);
            }

            return(matchedWindowNode);
        }
        public bool AddToDo()
        {
            TestStack.White.UIItems.WindowItems.Window todoWindow = null;
            qbApp = QuickBooks.GetApp("QuickBooks");
            qbWindow = QuickBooks.GetAppWindow(qbApp, "Vincent");
            remWindow = Actions.GetWindow(qbWindow, "Reminders");
            silkRemWindow = _desktop.Window("@caption='Reminders'");
            silkRemWindow.Maximize();
            Actions.ClickElementByAutomationID(remWindow, "120");
            todoWindow = Actions.GetChildWindow(qbWindow, "Add To Do");
            Actions.SelectComboBoxItemByText(todoWindow, "cbType", "Appointment");
            Actions.SelectComboBoxItemByText(todoWindow, "cbPriority", "High");
            Actions.SetTextOnElementByAutomationID(todoWindow, "todoDetails", "Pay vendors");
            Actions.ClickElementByName(todoWindow, "OK");

            return true;
        }
Beispiel #19
0
        private void button1_Click(object sender, EventArgs e)
        {
            TestStack.White.Application app =
                TestStack.White.Application
                .Launch(@"C:\Users\Luis\Desktop\Crawler\WebBrowser\WebBrowser\bin\Debug\WebBrowser.exe");

            Window window = app.GetWindow("Titulos");

            SearchCriteria criteria = SearchCriteria.ByText("Com estrela");

            var link = window.Get <Hyperlink>(criteria);

            link.Click();


            //TestStack.White.UIItems.Hyperlink link;
            //link.GetElement(criteria);
        }
        public void TestMethod1()
        {
            Logger test = new Logger("UnitTest");
            bool res = false;
            qbApp = QuickBooks.GetApp("QuickBooks");
            qbWindow = QuickBooks.GetAppWindow(qbApp, "Vincent");
            Actions.SelectMenu(qbApp, qbWindow, "Company", "Reminders");
            remWindow = Actions.GetWindow(qbWindow, "Reminders");

            //Add a todo note
            //res=AddToDo();
            //Assert.AreEqual(true, res, "To Do creation failed");


            silkRemWindow = _desktop.Window("@caption='Reminders'");
            silkRemWindow.Maximize();
           
            var list = silkRemWindow.GetChildren();

            //string a ="TO DO NOTES ( 1 )";
            //string count = a.Split(new char[] { '(', ')' })[1].Trim(); ;

            var textBoxes = remWindow.GetMultiple(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Edit));
            var panels = remWindow.GetMultiple(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Pane));
            var customUIItems = remWindow.GetMultiple(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Custom));
            var groupBoxes = remWindow.GetMultiple(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Group));
            var buttons = remWindow.GetMultiple(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Button));
            var thumbs = remWindow.GetMultiple(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Thumb));
            var wpfLabels = remWindow.GetMultiple(SearchCriteria.ByControlType(System.Windows.Automation.ControlType.Text));

            //foreach (TestStack.White.UIItems.GroupBox g in groupBoxes)
            //{
            //    //var gChild = 

            //}
            foreach (TestStack.White.UIItems.Button b in buttons)
            {
                if(b.Name.Contains("TO DO"))
                    Actions.ClickButtonByAutomationID(remWindow, "ExpanderButton");
            }
            list = silkRemWindow.GetChildren();
            var a = remWindow.GetMultiple(SearchCriteria.All);

        }
Beispiel #21
0
            public void UpdateDigitsWhenGreaterThanMax(string containerId)
            {
                using (var app = Application.AttachOrLaunch(Info.ProcessStartInfo))
                {
                    var window = app.GetWindow(AutomationIds.MainWindow, InitializeOption.NoCache);
                    var page   = window.Get <TabPage>(AutomationIds.DebugTab);
                    page.Select();
                    var groupBox   = window.Get <GroupBox>(AutomationIds.DoubleBoxGroupBox);
                    var container  = groupBox.Get <UIItemContainer>(containerId);
                    var inputBox   = container.Get <TextBox>(AutomationIds.InputBox);
                    var digitsBox  = groupBox.Get <TextBox>(AutomationIds.DigitsBox);
                    var maxBox     = groupBox.Get <TextBox>(AutomationIds.MaxBox);
                    var vmValueBox = groupBox.Get <TextBox>(AutomationIds.VmValueBox);
                    Assert.AreEqual("0", inputBox.Text);
                    inputBox.Enter("1.2");
                    Assert.AreEqual("1.2", inputBox.Text);
                    Assert.AreEqual(false, inputBox.HasValidationError());
                    Assert.AreEqual("0", vmValueBox.Text);
                    Assert.AreEqual("1.2", inputBox.Value());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());

                    maxBox.Enter("1");
                    vmValueBox.Click();
                    Assert.AreEqual("1.2", inputBox.Text);
                    Assert.AreEqual(true, inputBox.HasValidationError());
                    Assert.AreEqual("1.2", vmValueBox.Text);
                    Assert.AreEqual("1.2", inputBox.Value());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());


                    digitsBox.Enter("4");
                    vmValueBox.Click();
                    Assert.AreEqual("1.2", inputBox.EditText());
                    Assert.AreEqual("1.2000", inputBox.FormattedText());
                    Assert.AreEqual(true, inputBox.HasValidationError());
                    Assert.AreEqual("1.2", vmValueBox.Text);
                    Assert.AreEqual("1.2", inputBox.Value());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());
                }
            }
Beispiel #22
0
            public void ValidationTriggerLostFocus(string containerId)
            {
                using (var app = Application.AttachOrLaunch(Info.ProcessStartInfo))
                {
                    var window = app.GetWindow(AutomationIds.MainWindow, InitializeOption.NoCache);
                    var page   = window.Get <TabPage>(AutomationIds.DebugTab);
                    page.Select();
                    var groupBox  = window.Get <GroupBox>(AutomationIds.DoubleBoxGroupBox);
                    var container = groupBox.Get <UIItemContainer>(containerId);
                    var inputBox  = container.Get <TextBox>(AutomationIds.InputBox);
                    groupBox.Get <ComboBox>(AutomationIds.ValidationTriggerBox).Select(ValidationTrigger.LostFocus.ToString());
                    var vmValueBox = groupBox.Get <TextBox>(AutomationIds.VmValueBox);
                    Assert.AreEqual("0", inputBox.Text);
                    Assert.AreEqual("0", inputBox.Value());
                    Assert.AreEqual(TextSource.ValueBinding, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());
                    inputBox.Enter("1.2");
                    vmValueBox.Click();
                    Assert.AreEqual("1.2", vmValueBox.Text);
                    Assert.AreEqual(false, inputBox.HasValidationError());
                    Assert.AreEqual("1.2", inputBox.Value());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());

                    inputBox.Enter("ggg");
                    Assert.AreEqual("ggg", inputBox.EditText());
                    Assert.AreEqual("1.2", inputBox.FormattedText());
                    Assert.AreEqual("1.2", inputBox.Value());
                    Assert.AreEqual("1.2", vmValueBox.Text);
                    Assert.AreEqual(false, inputBox.HasValidationError());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());

                    vmValueBox.Click();
                    Assert.AreEqual("ggg", inputBox.EditText());
                    Assert.AreEqual("ggg", inputBox.FormattedText());
                    Assert.AreEqual("1.2", inputBox.Value());
                    Assert.AreEqual("1.2", vmValueBox.Text);
                    Assert.AreEqual(true, inputBox.HasValidationError());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());
                }
            }
Beispiel #23
0
        public void TestWhiteStack()
        {
            Process proc = Process.GetProcessesByName(windowName[0])[0];

            TestStack.White.Application app = TestStack.White.Application.Attach(proc);

            /*List<Window> windows = app.GetWindows();
             * foreach(Window w in windows)
             * {
             *  logDebug(w.Title);
             * }*/
            Window w = app.GetWindow("BlueStacks App Player");

            logDebug("Found=" + w.Title);
            logDebug(w.Mouse.Location.ToString());
            w.Mouse.Location = new System.Windows.Point(50, 50);
            logDebug(w.Mouse.Location.ToString());
            //w.Mouse.Click();
        }
Beispiel #24
0
        //This function attach the PSC process to application
        public static Application attachPSC()
        {
            //Looking for PSC process

            int thernosid = 0;

            Process[] procs = Process.GetProcesses();
            foreach (Process proc in procs)
            {
                if (proc.ProcessName == "PSC.QA")
                {
                    thernosid = proc.Id;
                }
            }

            application = TestStack.White.Application.Attach(thernosid);
            Console.WriteLine("Waiting for 5 seconds before attaching the process");
            Thread.Sleep(5000);
            return(application);
        }
Beispiel #25
0
            public void Min(string containerId)
            {
                using (var app = Application.AttachOrLaunch(Info.ProcessStartInfo))
                {
                    var window = app.GetWindow(AutomationIds.MainWindow, InitializeOption.NoCache);
                    var page   = window.Get <TabPage>(AutomationIds.DebugTab);
                    page.Select();
                    var groupBox   = window.Get <GroupBox>(AutomationIds.DoubleBoxGroupBox);
                    var container  = groupBox.Get <UIItemContainer>(containerId);
                    var inputBox   = container.Get <TextBox>(AutomationIds.InputBox);
                    var minBox     = groupBox.Get <TextBox>(AutomationIds.MinBox);
                    var vmValueBox = groupBox.Get <TextBox>(AutomationIds.VmValueBox);
                    Assert.AreNotEqual("1.2", inputBox.Text);
                    inputBox.Enter("1.2");
                    vmValueBox.Click();
                    Assert.AreEqual("1.2", inputBox.Text);
                    Assert.AreEqual("1.2", vmValueBox.Text);

                    minBox.Enter("4");
                    vmValueBox.Click();
                    Assert.AreEqual(true, inputBox.HasValidationError());
                    Assert.AreEqual("1.2", inputBox.Text);
                    Assert.AreEqual("1.2", vmValueBox.Text);

                    inputBox.Enter("2.3");
                    Assert.AreEqual("2.3", inputBox.Text);
                    Assert.AreEqual(true, inputBox.HasValidationError());
                    Assert.AreEqual("1.2", vmValueBox.Text);

                    minBox.Enter("-2");
                    vmValueBox.Click();
                    Assert.AreEqual("2.3", inputBox.Text);
                    Assert.AreEqual(false, inputBox.HasValidationError());
                    Assert.AreEqual("1.2", vmValueBox.Text); // maybe we want to update source here idk.

                    inputBox.Enter("5.6");
                    vmValueBox.Click();
                    Assert.AreEqual("5.6", inputBox.Text);
                    Assert.AreEqual("5.6", vmValueBox.Text);
                }
            }
Beispiel #26
0
        private static void Main(string[] args)
        {
            //okta-signin-username
            //okta-signin-password
            //okta-signin-submit
            //ZscalerApp

            Process.Start(@"C:\Program Files (x86)\Zscaler\ZSATray\ZSATray.exe");
            Thread.Sleep(5000);
            var process = Process.GetProcessesByName("ZSATray").FirstOrDefault();

            if (process != null)
            {
                var application = Application.Attach(process.Id);
                var window      = application.GetWindow(SearchCriteria.ByAutomationId("ZscalerApp"), InitializeOption.NoCache);

                var userNameTextBox = window.Get <TextBox>(SearchCriteria.ByAutomationId("ZSAUNFUserNameText"));
                var loginButton     = window.Get <Button>(SearchCriteria.ByAutomationId("ZSAUNFLoginButton"));

                userNameTextBox.Text = "";
                loginButton.Click();

                Thread.Sleep(10000);

                AutomationElement username = FindChildElement("okta-signin-username", window.AutomationElement)[0];
                username.SetFocus();
                InsertText(username, "");
                SendKeys.SendWait("");

                AutomationElement password = FindChildElement("okta-signin-password", window.AutomationElement)[0];

                password.SetFocus();
                SendKeys.SendWait("!");

                AutomationElement submit = FindChildElement("okta-signin-submit", window.AutomationElement)[0];
                submit.SetFocus();
                SendKeys.SendWait("{ENTER}");
            }

            Console.ReadKey();
        }
Beispiel #27
0
            public void NumberStylesAllowLeadingSign(string containerId)
            {
                using (var app = Application.AttachOrLaunch(Info.ProcessStartInfo))
                {
                    var window = app.GetWindow(AutomationIds.MainWindow, InitializeOption.NoCache);
                    var page   = window.Get <TabPage>(AutomationIds.DebugTab);
                    page.Select();
                    var groupBox   = window.Get <GroupBox>(AutomationIds.DoubleBoxGroupBox);
                    var container  = groupBox.Get <UIItemContainer>(containerId);
                    var inputBox   = container.Get <TextBox>(AutomationIds.InputBox);
                    var signBox    = groupBox.Get <CheckBox>(AutomationIds.AllowLeadingSignBox);
                    var vmValueBox = groupBox.Get <TextBox>(AutomationIds.VmValueBox);
                    inputBox.Enter("-1.2");
                    vmValueBox.Click();
                    Assert.AreEqual("-1.2", inputBox.Text);
                    Assert.AreEqual(false, inputBox.HasValidationError());
                    Assert.AreEqual("-1.2", vmValueBox.Text);
                    Assert.AreEqual("-1.2", inputBox.Value());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());

                    signBox.Checked = false;
                    vmValueBox.Click();
                    Assert.AreEqual("-1.2", inputBox.Text);
                    Assert.AreEqual(true, inputBox.HasValidationError());
                    Assert.AreEqual("-1.2", vmValueBox.Text);
                    Assert.AreEqual("-1.2", inputBox.Value());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());

                    signBox.Checked = true;
                    vmValueBox.Click();
                    Assert.AreEqual("-1.2", inputBox.Text);
                    Assert.AreEqual(false, inputBox.HasValidationError());
                    Assert.AreEqual("-1.2", vmValueBox.Text);
                    Assert.AreEqual("-1.2", inputBox.Value());
                    Assert.AreEqual(TextSource.UserInput, inputBox.TextSource());
                    Assert.AreEqual(Status.Idle, inputBox.Status());
                }
            }
Beispiel #28
0
            public void CopyTest()
            {
                using (var app = Application.AttachOrLaunch(Info.ProcessStartInfo))
                {
                    var window = app.GetWindow(AutomationIds.MainWindow, InitializeOption.NoCache);
                    var page   = window.Get <TabPage>(AutomationIds.DebugTab);
                    page.Select();
                    var groupBox         = window.Get <GroupBox>(AutomationIds.DoubleBoxGroupBox);
                    var inputBox         = groupBox.Get <TextBox>(AutomationIds.InputBox);
                    var attachedKeyboard = window.Keyboard;
                    inputBox.Text = "1.2";
                    attachedKeyboard.HoldKey(KeyboardInput.SpecialKeys.CONTROL);
                    attachedKeyboard.Enter("ac");
                    attachedKeyboard.LeaveKey(KeyboardInput.SpecialKeys.CONTROL);

                    //check the text is the same as that on the clipboard
                    Retry.For(() =>
                    {
                        var clipboardText = Clipboard.GetText();
                        Assert.AreEqual("1.2", clipboardText);
                    }, TimeSpan.FromSeconds(5));
                }
            }
Beispiel #29
0
 public void Undo(string containerId)
 {
     using (var app = Application.AttachOrLaunch(Info.ProcessStartInfo))
     {
         var window = app.GetWindow(AutomationIds.MainWindow, InitializeOption.NoCache);
         var page   = window.Get <TabPage>(AutomationIds.DebugTab);
         page.Select();
         var groupBox   = window.Get <GroupBox>(AutomationIds.DoubleBoxGroupBox);
         var container  = groupBox.Get <UIItemContainer>(containerId);
         var inputBox   = container.Get <TextBox>(AutomationIds.InputBox);
         var vmValueBox = groupBox.Get <TextBox>(AutomationIds.VmValueBox);
         Assert.AreEqual("0", inputBox.Text);
         var keyboard = window.Keyboard;
         inputBox.Click();
         keyboard.Enter("1");
         Assert.AreEqual("10", inputBox.Text);
         keyboard.HoldKey(KeyboardInput.SpecialKeys.CONTROL);
         keyboard.Enter("z");
         keyboard.LeaveKey(KeyboardInput.SpecialKeys.CONTROL);
         Assert.AreEqual("0", inputBox.Text);
         Assert.AreEqual("0", vmValueBox.Text);
     }
 }
Beispiel #30
0
        //private UTILS _utils = new UTILS();

        // Perry Hunter 06/10/2013
        ///<summary>Selects the specified tab in the AWG Main Window</summary>
        /// <summary>PREREQUISITE: AWG mode is selected</summary>
        ///<param name="tabName">The AutomationID (name) of the tab to select</param>
        public static void SelectMainTabControl(string tabName)
        {
            if (AwgSetupSteps.IgnoreUi)
            {
                return;
            }

            IAWG awg = AwgSetupSteps.GetAWG("1");
            //awg.DiagComment("Selecting the " + tabName + " tab control in " + awg.ModelString + " window");

            //Find the AWG application
            Application application = Application.Attach(AWGUI.ProcessName);

            Assert.IsNotNull(application);

            //Find the main window by it's AutomationID
            Window window = application.GetWindow(awg.ModelString);

            Assert.IsNotNull(window);

            //Find the requested tab by it's AutomationID (in WPF, this is name property)
            var panelMain = (Panel)window.Get(SearchCriteria.ByAutomationId("containerMain"));

            Assert.IsNotNull(panelMain);

            //Our tab isn't really a tab. It's a panel contro
            var tab = (Panel)panelMain.Get(SearchCriteria.ByAutomationId(tabName));

            Assert.IsNotNull(tab);

            //Check the IsEnabled property
            Assert.IsTrue(tab.Enabled.Equals(true), tabName + " was not enabled, could not select when requested");

            //Click it
            tab.Click();
        }
 public void Setup()
 {
     qbApp = FrameworkLibraries.AppLibs.QBDT.WhiteAPI.QuickBooks.Initialize(exe);
     qbWindow = FrameworkLibraries.AppLibs.QBDT.WhiteAPI.QuickBooks.PrepareBaseState(qbApp);
     QuickBooks.ResetQBWindows(qbApp, qbWindow);
 }
 public static void Initialize()
 {
     qbApp = FrameworkLibraries.AppLibs.WhiteAPI.QuickBooks.Initialize(exe);
     qbWindow = FrameworkLibraries.AppLibs.WhiteAPI.QuickBooks.PrepareBaseState(qbApp);
     InitQB();
     if (!qbWindow.Title.Contains("COSMETICS"))
     {
         FrameworkLibraries.AppLibs.WhiteAPI.QuickBooks.OpenOrUpgradeCompanyFile(DefaultCompanyFilePath, qbApp, qbWindow, false, false);
     }
     qbWindow.Focus();
     Reports.ResetQBPrefForCommentedReports(qbApp, qbWindow);
 }
 internal void LaunchApp()
 {
     Debug.Assert(App == null);
     App = LaunchApp(this.appPath);
 }
 private static void TryEnable(string driverName, MMDevice mMDevice)
 {
     try
     {
         var hwnd = 0;
         hwnd = FindWindow(null, "Sound");
         Process soundProc;
         if (hwnd == 0)
         {
             soundProc = Process.Start("control.exe", "mmsys.cpl,,1");
         }
         else
         {
             CloseWindow((IntPtr)hwnd);
             while (hwnd == 0)
             {
                 Debug.WriteLine($"Waiting to Close ...");
                 Task.Delay(1000);
                 hwnd = FindWindow(null, "Sound");
             }
             soundProc = Process.Start("control.exe", "mmsys.cpl,,1");
         }
         hwnd = 0;
         hwnd = FindWindow(null, "Sound");
         while (hwnd == 0)
         {
             Debug.WriteLine($"Waiting ...");
             Task.Delay(1000);
             hwnd = FindWindow(null, "Sound");
         }
         if (hwnd == 0)
         {
             MessageBox.Show($"Couldnt find Sound Window.");
             return;
         }
         var id = GetWindowThreadProcessId((IntPtr)hwnd, out uint i);
         TestStack.White.Application application = TestStack.White.Application.Attach((int)i);
         Debug.WriteLine($"{application.Name}");
         TestStack.White.UIItems.WindowItems.Window window = application.GetWindow("Sound");
         var exists = window.Exists(TestStack.White.UIItems.Finders.SearchCriteria.ByText(driverName));
         if (exists)
         {
             TestStack.White.UIItems.ListBoxItems.ListItem listItem = window.Get <TestStack.White.UIItems.ListBoxItems.ListItem>(TestStack.White.UIItems.Finders.SearchCriteria.ByText(driverName));
             listItem.Focus();
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.UP);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.DOWN);
             window.Keyboard.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.F10);
             window.Keyboard.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.Enter("E");
         }
         else
         {
             window.Keyboard.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.F10);
             window.Keyboard.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.Enter("S");
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.RETURN);
             TestStack.White.UIItems.ListBoxItems.ListItem listItem = window.Get <TestStack.White.UIItems.ListBoxItems.ListItem>(TestStack.White.UIItems.Finders.SearchCriteria.ByText(driverName));
             listItem.Focus();
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.UP);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.DOWN);
             window.Keyboard.HoldKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.PressSpecialKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.F10);
             window.Keyboard.LeaveKey(TestStack.White.WindowsAPI.KeyboardInput.SpecialKeys.SHIFT);
             window.Keyboard.Enter("E");
         }
         if (mMDevice != null)
         {
             if (mMDevice.State == DeviceState.Active)
             {
                 Debug.WriteLine($"{ mMDevice.FriendlyName}");
                 CloseWindow((IntPtr)hwnd);
             }
             else
             {
                 MessageBox.Show("Please Enable the device ");
             }
         }
     }
     catch (Exception)
     {
     }
 }
Beispiel #35
0
        static void Main(string[] args)
        {
            for (int i = 0; i < Convert.ToInt32(args[1]); i++)
            {
                StreamWriter file2     = new StreamWriter(@"e:\RunningTimeWhiteLogin.txt", true);
                Stopwatch    stopwatch = Stopwatch.StartNew(); //creates and start the instance of Stopwatch

                var psi = new ProcessStartInfo(@"C:\\Users\\pth\\AppData\\Local\\Personify\\Omni\\Personify.exe");
                TestStack.White.Application app = TestStack.White.Application.AttachOrLaunch(psi);
                int    numWaits = 0;
                Window window;
                do
                {
                    Console.WriteLine("\n Looking for Chat application...");
                    // Find window with title "Personify"
                    window = app.GetWindow("Personify", TestStack.White.Factory.InitializeOption.NoCache);
                    ++numWaits;
                    Thread.Sleep(100);
                } while (window == null && numWaits < 50);
                Assert.IsNotNull(window);
                TestStack.White.UIItems.TextBox username = window.Get <TestStack.White.UIItems.TextBox>(SearchCriteria.ByAutomationId("Username"));
                TestStack.White.UIItems.TextBox password = window.Get <TestStack.White.UIItems.TextBox>(SearchCriteria.ByAutomationId("Password"));

                if (username == null || password == null)
                {
                    Assert.Fail("!!Can not find any textbox");
                }

                AutomationElement aeTemp = TreeWalker.ControlViewWalker.GetNextSibling(password.AutomationElement);
                // Input valid nxchattest1 user account to sign in.
                AutomationElement aeSignInButton      = TreeWalker.ControlViewWalker.GetNextSibling(aeTemp);
                TestStack.White.UIItems.Button signIn = new TestStack.White.UIItems.Button(aeSignInButton, window.ActionListener);
                username.BulkText = "";
                password.BulkText = "";
                signIn.Click();
                Thread.Sleep(1000);
                username.BulkText = "*****@*****.**";
                password.BulkText = "123456";
                signIn.Click();
                Thread.Sleep(2000);
                // Waiting for Chat Deck Window display
                numWaits = 0;
                do
                {
                    Console.WriteLine("\n Looking for Chat Deck...");
                    window = app.GetWindow("Home", TestStack.White.Factory.InitializeOption.NoCache);
                    ++numWaits;
                    Thread.Sleep(100);
                } while (window == null && numWaits < 50);


                //TestStack.White.UIItems.TextBox texttemp = window.Get<TestStack.White.UIItems.TextBox>(SearchCriteria.ByText("Create an immersive recording with your persona and content on screen."));
                TestStack.White.UIItems.Label  texttemp = window.Get <TestStack.White.UIItems.Label>(SearchCriteria.ByNativeProperty(AutomationElement.NameProperty, "Create an immersive recording with your persona and content on screen."));
                AutomationElement              aemenu   = TreeWalker.ControlViewWalker.GetNextSibling(texttemp.AutomationElement);
                TestStack.White.UIItems.Button menubtn  = new TestStack.White.UIItems.Button(aemenu, window.ActionListener);
                menubtn.Toggle();
                TestStack.White.UIItems.MenuItems.Menu signout = window.Get <TestStack.White.UIItems.MenuItems.Menu>(SearchCriteria.ByText("Sign out"));
                signout.Click();
                app.Kill();
                stopwatch.Stop();
                file2.WriteLine(stopwatch.ElapsedMilliseconds + " miliseconds");
                file2.Close();
            }
        }