Пример #1
0
        public void TestMethod1()
        {
            Application app    = base.Application;
            Window      window = app.GetWindow(SearchCriteria.ByAutomationId("StartScreen"), InitializeOption.WithCache);

            Add_Level_Data();
            window.WaitWhileBusy();
            //click the cont button
            Button contBtn = window.Get <Button>(SearchCriteria.ByAutomationId("button2"));

            contBtn.Click();

            // get cont window
            Window cont = app.GetWindow(SearchCriteria.ByAutomationId("ContinueGame"), InitializeOption.WithCache);

            cont.WaitWhileBusy();

            IUIItem[] children1 = cont.GetMultiple(SearchCriteria.All);
            //get lvl 2 button
            Button lvl2Btn = (Button)children1[3];

            lvl2Btn.Click();
            // get game window
            Window game = app.GetWindow(SearchCriteria.ByAutomationId("Form3"), InitializeOption.NoCache);

            AttachedKeyboard keyboard = game.Keyboard;

            keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.RIGHT);
            keyboard.HoldKey(KeyboardInput.SpecialKeys.SPACE);   // jump to cloud
            keyboard.LeaveKey(KeyboardInput.SpecialKeys.SPACE);
            game.ReloadIfCached();
            keyboard.PressSpecialKey(KeyboardInput.SpecialKeys.SPACE);
            keyboard.HoldKey(KeyboardInput.SpecialKeys.SPACE); // die by moon
            keyboard.LeaveKey(KeyboardInput.SpecialKeys.SPACE);

            Window lost = app.GetWindow(SearchCriteria.ByAutomationId("DeathBox3"), InitializeOption.WithCache);

            children1 = lost.GetMultiple(SearchCriteria.All); //3-cont 4-save

            Button saveBtn = (Button)children1[4];

            saveBtn.Click();

            contBtn = (Button)children1[3];
            contBtn.Click();

            game = app.GetWindow(SearchCriteria.ByAutomationId("Form3"), InitializeOption.NoCache);
            game.Close();
            app.Close();
            app.Dispose();
        }
        public void TestMethod1()
        {
            Application app    = base.Application;
            Window      window = app.GetWindow(SearchCriteria.ByAutomationId("StartScreen"), InitializeOption.WithCache);

            Add_Level_Data();
            window.WaitWhileBusy();
            //click the cont button
            Button contBtn = window.Get <Button>(SearchCriteria.ByAutomationId("button2"));

            contBtn.Click();

            // get cont window
            Window cont = app.GetWindow(SearchCriteria.ByAutomationId("ContinueGame"), InitializeOption.WithCache);

            cont.WaitWhileBusy();

            IUIItem[] children1 = cont.GetMultiple(SearchCriteria.All);
            //get lvl 2 button
            Button lvl2Btn = (Button)children1[2];

            lvl2Btn.Click();
            // get game window
            Window game = app.GetWindow(SearchCriteria.ByAutomationId("Form2"), InitializeOption.WithCache);

            game.WaitWhileBusy(); //wait till lightening kills player

            AttachedKeyboard keyboard = game.Keyboard;

            keyboard.HoldKey(KeyboardInput.SpecialKeys.RIGHT); //die by black hole
            keyboard.LeaveKey(KeyboardInput.SpecialKeys.RIGHT);


            // put stuff here to win


            Window win = app.GetWindow(SearchCriteria.ByAutomationId("Level2Complete"), InitializeOption.WithCache);

            win.WaitWhileBusy();
            children1 = win.GetMultiple(SearchCriteria.All); //4-save 5-quit
            Button saveBtn = (Button)children1[4];

            saveBtn.Click();
            win.WaitWhileBusy();

            Button quitBtn = (Button)children1[5];

            quitBtn.Click();

            app.Close();
            app.Dispose();
        }
Пример #3
0
        public void CopyTest()
        {
            AttachedKeyboard attachedKeyboard = Window.Keyboard;

            textBox.Text = "userText";
            attachedKeyboard.HoldKey(KeyboardInput.SpecialKeys.CONTROL);
            attachedKeyboard.Enter("ac");
            attachedKeyboard.LeaveKey(KeyboardInput.SpecialKeys.CONTROL);
            Thread.Sleep(100);

            //check the text is the same as that on the clipboard
            string clipbrdText = Clipboard.GetText();

            Assert.AreEqual(textBox.Text, clipbrdText, "Text on clipboard does not match expected");
        }
Пример #4
0
        public void TestMethod1()
        {
            Application app    = base.Application;
            Window      window = app.GetWindow(SearchCriteria.ByAutomationId("StartScreen"), InitializeOption.WithCache);

            Delete_LevelData();
            window.WaitWhileBusy();
            //click the cont button
            Button contBtn = window.Get <Button>(SearchCriteria.ByAutomationId("button2"));

            contBtn.Click();

            // get cont window
            Window cont = app.GetWindow(SearchCriteria.ByAutomationId("ContinueGame"), InitializeOption.WithCache);

            cont.WaitWhileBusy();

            IUIItem[] children1 = cont.GetMultiple(SearchCriteria.All);
            //get lvl 1 button
            Button lvl1Btn = (Button)children1[1];

            lvl1Btn.Click();
            // get game window
            Window game = app.GetWindow(SearchCriteria.ByAutomationId("Form1"), InitializeOption.WithCache);

            AttachedKeyboard keyboard = game.Keyboard;

            keyboard.HoldKey(KeyboardInput.SpecialKeys.RIGHT);  //die by black hole
            //keyboard.LeaveKey(KeyboardInput.SpecialKeys.RIGHT);

            Window lost = app.GetWindow(SearchCriteria.ByAutomationId("DeathBox"), InitializeOption.WithCache);

            keyboard.LeaveKey(KeyboardInput.SpecialKeys.RIGHT);
            lost.WaitWhileBusy();
            children1 = lost.GetMultiple(SearchCriteria.All); //35

            Button saveBtn = (Button)children1[4];

            saveBtn.Click();
            lost.WaitWhileBusy();

            Button quitBtn = (Button)children1[5];

            quitBtn.Click();

            app.Close();
            app.Dispose();
        }
Пример #5
0
        private static void SendKeysToMenu(string[] keys)
        {
            AttachedKeyboard keyboard = mainWindow.Keyboard;

            //Log("Sending ALT");
            keyboard.HoldKey(KeyboardInput.SpecialKeys.ALT);
            foreach (var key in keys)
            {
                //logger.Log($"Sending {key}");
                keyboard.Enter(key);
                Thread.Sleep(200);
            }

            keyboard.LeaveKey(KeyboardInput.SpecialKeys.ALT);
            Thread.Sleep(1000);
            //logger.Log($"{mainWindow.Title}");
        }
Пример #6
0
        void CopyTest()
        {
            var textBox = MainWindow.Get <TextBox>("TextBox");
            AttachedKeyboard attachedKeyboard = MainWindow.Keyboard;

            textBox.Text = "userText";
            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(() =>
            {
                string clipbrdText = Clipboard.GetText();
                Assert.Equal(textBox.Text, clipbrdText);
            }, TimeSpan.FromSeconds(5));
        }
Пример #7
0
 public static void PressSpecialKey(this AttachedKeyboard keyboard, KeyboardInput.SpecialKeys holdKey, KeyboardInput.SpecialKeys specialKey)
 {
     keyboard.HoldKey(holdKey);
     keyboard.PressSpecialKey(specialKey);
     keyboard.LeaveKey(holdKey);
 }