private void SetOpacity(WindowsElement editor, string key)
 {
     editor.Click();                                                                 //activate
     editor.SendKeys(OpenQA.Selenium.Keys.Control + OpenQA.Selenium.Keys.Backspace); //clear previous value
     editor.SendKeys(key);
     editor.SendKeys(OpenQA.Selenium.Keys.Enter);                                    //confirm changes
 }
 public void Cleanup()
 {
     // Select all text and delete to clear the edit box
     NotepadMainEditBox.SendKeys(Keys.Control + "a" + Keys.Control);
     NotepadMainEditBox.SendKeys(Keys.Delete);
     Assert.AreEqual(string.Empty, NotepadMainEditBox.Text);
 }
Beispiel #3
0
 public void TestInitialize()
 {
     // Select all text and delete to clear the edit box
     editBox.SendKeys(Keys.Control + "a" + Keys.Control);
     editBox.SendKeys(Keys.Delete);
     Assert.AreEqual(string.Empty, editBox.Text);
 }
Beispiel #4
0
 public void TestInitialize()
 {
     // Clearing the edit box
     editBox.SendKeys(Keys.Control + "a" + Keys.Control);
     editBox.SendKeys(Keys.Delete);
     Assert.AreEqual(string.Empty, editBox.Text);
 }
Beispiel #5
0
        private void SetLayoutName(string name)
        {
            WindowsElement textBox = session.FindElementByClassName("TextBox");

            textBox.Click();
            textBox.SendKeys(Keys.Control + "a");
            textBox.SendKeys(Keys.Backspace);
            textBox.SendKeys(name);
        }
Beispiel #6
0
 public void Clear()
 {
     textBoxElement1.Clear();
     Assert.AreEqual(string.Empty, textBoxElement1.Text);
     textBoxElement1.SendKeys("fghij67890^&*()");
     Assert.AreEqual("fghij67890^&*()", textBoxElement1.Text);
     textBoxElement1.Clear();
     Assert.AreEqual(string.Empty, textBoxElement1.Text);
 }
Beispiel #7
0
 public static void InputId(int faceId, WindowsElement idBox, Actions action,
                            WindowsDriver <WindowsElement> sessionJpt, WindowsElement find)
 {
     idBox.SendKeys(Keys.Control + "a" + Keys.Control);
     idBox.SendKeys(Convert.ToString(faceId));
     action = new Actions(sessionJpt);
     action.MoveToElement(find);
     action.MoveToElement(find, find.Size.Width / 2 - 30, find.Size.Height / 3 - 8).Click().Perform();
 }
Beispiel #8
0
 public void SendKeys()
 {
     // Use the cursor key to scroll through the entries in the combo box
     comboBoxElement1.SendKeys(Keys.Down + Keys.Up + Keys.Up + Keys.Up); // Ensure top entry is selected
     Assert.AreEqual("Blue", comboBoxElement1.Text);
     comboBoxElement1.SendKeys(Keys.Down);
     Assert.AreEqual("Green", comboBoxElement1.Text);
     comboBoxElement1.SendKeys(Keys.Up);
     Assert.AreEqual("Blue", comboBoxElement1.Text);
 }
Beispiel #9
0
        public void EnterUsername(String username)
        {
            WindowsElement usernameField = Driver.FindElementByName("Username Field");

            if (usernameField != null)
            {
                usernameField.SendKeys(Keys.Control + "a");
                usernameField.SendKeys(Keys.Delete);
            }
            usernameField.SendKeys(username);
        }
        public void SendKeys()
        {
            var originalValue = sliderElement1.Text;

            // Pressing right arrow will move the slider right and the value should increase by 1
            sliderElement1.SendKeys(Keys.Right);
            Assert.AreEqual(int.Parse(originalValue) + 1, int.Parse(sliderElement1.Text));
            // Pressing left arrow will move the slider back to the original value
            sliderElement1.SendKeys(Keys.Left);
            Assert.AreEqual(originalValue, sliderElement1.Text);
        }
Beispiel #11
0
        public void Test_10_MaskEditInput()
        {
            WindowsElement nexaMaskEdit00 = session.FindElementByAccessibilityId("mainframe.ChildFrame00.form.MaskEdit00");

            Assert.IsNotNull(nexaMaskEdit00);
            Thread.Sleep(TimeSpan.FromSeconds(0.1));

            nexaMaskEdit00.Clear();
            nexaMaskEdit00.Click();
            nexaMaskEdit00.SendKeys(Keys.Control + "a");
            Thread.Sleep(TimeSpan.FromSeconds(0.1));
            nexaMaskEdit00.SendKeys("abcde1234" + Keys.Enter);
            Assert.AreEqual("abcde-1234", nexaMaskEdit00.Text);
        }
Beispiel #12
0
        public void LocalSearch()
        {
            // Type "add" in Cortana search box
            searchBox.SendKeys("add");
            Thread.Sleep(TimeSpan.FromSeconds(1));
            var bingPane = cortanaSession.FindElementByName("Bing");

            Assert.IsNotNull(bingPane);

            // Verify that a shortcut to "System settings Add or remove programs" is shown as a search result
            var bingResult = bingPane.FindElementByXPath("//DataItem[starts-with(@Name, \"Add or remove\")]");

            Assert.IsNotNull(bingResult);
            Assert.IsTrue(bingResult.Text.EndsWith("System settings"));
        }
Beispiel #13
0
        public void InputTextInNotepadWindow()
        {
            // Arrange.
            string expectedText = "Say hello world.";

            // Create an empty text file.
            DirectoryInfo currentTestFolder = CreateTestFolder(Path.GetRandomFileName());
            string        testFileFullPath  = Path.Combine(currentTestFolder.FullName, "myTestFile.txt");

            File.WriteAllText(testFileFullPath, "");

            IDictionary <string, string> additionalCapabilities = new Dictionary <string, string>();

            additionalCapabilities.Add("appWorkingDir", currentTestFolder.FullName);
            additionalCapabilities.Add("appArguments", testFileFullPath);

            using (WindowsDriver <WindowsElement> driver = InstanceWebDriver(additionalCapabilities))
            {
                // Act.
                WindowsElement editTextBox = driver.FindElementByClassName("Edit");
                editTextBox.SendKeys(expectedText);

                editTextBox.Click();

                // TODO: Fix SAVE Key combination.
                driver.Keyboard.PressKey(Keys.Control + "G" + Keys.Control);

                // Assert.
                Assert.AreEqual(expectedText, editTextBox.Text, $"The expected text was '{expectedText}' but found '{editTextBox.Text}'.");
            }
        }
Beispiel #14
0
        public void SearchAdvanceMovieTest()
        {
            string username = "******"; string password = "******";
            WindowsDriver <WindowsElement> session = Initialize();

            session = WorkflowLogin(session, username, password);
            Assert.AreEqual(session.WindowHandles.Count, 1);

            // Main Page
            session.SwitchTo().Window(session.WindowHandles.Last());
            Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0);

            WindowsElement eSearch = session.FindElementByAccessibilityId("btnSearchAdvance");

            eSearch.Click();

            session.SwitchTo().Window(session.WindowHandles[0]);
            WindowsElement eYear = session.FindElementByAccessibilityId("txtYear");

            eYear.SendKeys("2021");

            WindowsElement eSearchSubmit = session.FindElementByAccessibilityId("btnSearch");

            eSearchSubmit.Click();
            session.SwitchTo().Window(session.WindowHandles[0]);

            Assert.IsTrue(session.FindElementsByClassName("DataGridRow").Count > 0);
        }
Beispiel #15
0
        public void ReplaceWorld()
        {
            WindowsElement NotepadTextArea = DesktopSession.FindElementByAccessibilityId("15");

            NotepadTextArea.SendKeys("Hello World");
            WindowsElement EditButton = DesktopSession.FindElementByName("Edición");

            EditButton.Click();
            WindowsElement ReplaceButton = DesktopSession.FindElementByAccessibilityId("23");

            ReplaceButton.Click();
            WindowsElement FindWhatInput = DesktopSession.FindElementByAccessibilityId("1152");

            FindWhatInput.Clear();
            FindWhatInput.SendKeys("World");
            WindowsElement ReplaceWithInput = DesktopSession.FindElementByAccessibilityId("1153");

            ReplaceWithInput.Clear();
            ReplaceWithInput.SendKeys("QA Engineers");
            WindowsElement ReplaceAllButton = DesktopSession.FindElementByName("Reemplazar todo");

            ReplaceAllButton.Click();
            WindowsElement CancelButton = DesktopSession.FindElementByAccessibilityId("2");

            CancelButton.Click();
            Assert.AreEqual("Hello QA Engineers", NotepadTextArea.Text);
            Console.WriteLine("Todo correcto!!!");
        }
Beispiel #16
0
        public void SendKeys_ModifierWindowsKey()
        {
            WindowsDriver <WindowsElement> desktopSession = Utility.CreateNewSession(CommonTestSettings.DesktopAppId);

            Assert.IsNotNull(desktopSession);

            // Launch action center using Window Keys + A
            session.Keyboard.PressKey(Keys.Command + "a" + Keys.Command);
            WindowsElement actionCenterElement = null;

            // Before Windows 10 Anniversary and Creators Update Action Center name had lower case c for "center"
            try
            {
                actionCenterElement = desktopSession.FindElementByName("Action Center");
            }
            catch
            {
                actionCenterElement = desktopSession.FindElementByName("Action center");
            }

            Assert.IsNotNull(actionCenterElement);

            // Dismiss action center and cleanup the temporary session
            actionCenterElement.SendKeys(Keys.Escape);
            editBox.Click();
            desktopSession.Quit();
        }
Beispiel #17
0
        public void GetElementText()
        {
            // Pivot Item element returns the name
            WindowsElement pivotItem = session.FindElementByAccessibilityId("StopwatchPivotItem");

            Assert.IsTrue(pivotItem.Text.StartsWith("Stopwatch")); // StopWatchPivotItem text is Stopwatch or Stopwatch tab on older app version

            // Button element returns the button name
            WindowsElement button = session.FindElementByAccessibilityId("AddAlarmButton");

            Assert.IsTrue(button.Text.Equals("Add new alarm") || button.Text.Equals("New")); // Add new alarm button is New on older app version
            button.Click();
            System.Threading.Thread.Sleep(TimeSpan.FromSeconds(1));

            // TextBlock element returns the text value
            WindowsElement textBlock = session.FindElementByAccessibilityId("EditAlarmHeader");

            Assert.AreEqual("NEW ALARM", textBlock.Text);

            // List element returns the value of the selected list item
            WindowsElement list = session.FindElementByAccessibilityId("MinuteLoopingSelector");

            Assert.AreEqual("00", list.Text);

            // TextBox element returns the text value
            WindowsElement textBox = session.FindElementByAccessibilityId("AlarmNameTextBox");

            textBox.Clear();
            Assert.AreEqual(string.Empty, textBox.Text);
            textBox.SendKeys("Test alarm name text box!");
            Assert.AreEqual("Test alarm name text box!", textBox.Text);
        }
        public void SpacingTestsInvalid()
        {
            OpenEditor();

            WindowsElement spaceAroundSetting     = session.FindElementByAccessibilityId("spaceAroundSetting");
            bool           editorShowSpacingValue = spaceAroundSetting.Selected;

            session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
            WaitSeconds(1);

            string[] invalidValues = { "!", "/", "<", "?", "D", "Z", "]", "m", "}", "1.5", "2,5" };

            string editorSpacingValue = GetEditZonesSetting <string>(editorSpacing);

            foreach (string value in invalidValues)
            {
                OpenEditor();

                WindowsElement paddingValue = WaitElementByAccessibilityId("paddingValue");
                ClearText(paddingValue);
                paddingValue.SendKeys(value);

                session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
                WaitSeconds(1);

                Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting <bool>(editorShowSpacing));
                Assert.AreEqual(editorSpacingValue, GetEditZonesSetting <string>(editorSpacing));
            }
        }
Beispiel #19
0
        public void SendKeysToElementError_ElementNotVisible()
        {
            base.TestInit();

            // Different Alarm & Clock application version uses different UI elements
            if (AlarmTabClassName == "ListViewItem")
            {
                // The latest Alarms & Clock application destroys the previous view instead of hiding it
            }
            else
            {
                // Navigate to Stopwatch tab and attempt to click on addAlarmButton that is no longer displayed
                WindowsElement addAlarmButton = session.FindElementByAccessibilityId("AddAlarmButton");
                session.FindElementByAccessibilityId(StopwatchTabAutomationId).Click();
                Thread.Sleep(TimeSpan.FromSeconds(1));
                Assert.IsFalse(addAlarmButton.Displayed);

                try
                {
                    addAlarmButton.SendKeys("keys");
                    Assert.Fail("Exception should have been thrown");
                }
                catch (InvalidOperationException exception)
                {
                    Assert.AreEqual(ErrorStrings.ElementNotVisible, exception.Message);
                }
            }
        }
        public void SpacingTestsValid()
        {
            OpenEditor();

            WindowsElement spaceAroundSetting     = session.FindElementByAccessibilityId("spaceAroundSetting");
            bool           editorShowSpacingValue = spaceAroundSetting.Selected;

            session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
            WaitSeconds(1);

            string[] validValues = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" };

            foreach (string editorSpacingValue in validValues)
            {
                OpenEditor();

                WindowsElement paddingValue = WaitElementByAccessibilityId("paddingValue");
                ClearText(paddingValue);
                paddingValue.SendKeys(editorSpacingValue);

                session.FindElementByAccessibilityId("ApplyTemplateButton").Click();
                WaitSeconds(1);

                Assert.AreEqual(editorShowSpacingValue, GetEditZonesSetting <bool>(editorShowSpacing));
                Assert.AreEqual(editorSpacingValue, GetEditZonesSetting <string>(editorSpacing));
            }
        }
Beispiel #21
0
        public void SendKeys()
        {
            Assert.AreEqual("0", sliderElement1.Text);

            // Pressing left arrow will not move the slider and it should still be at 0
            sliderElement1.SendKeys(Keys.Left);
            Assert.AreEqual("0", sliderElement1.Text);

            // Pressing right arrow will move the slider and it should 1
            sliderElement1.SendKeys(Keys.Right);
            Assert.AreEqual("1", sliderElement1.Text);

            // Pressing left arrow will move the slider back to 0
            sliderElement1.SendKeys(Keys.Left);
            Assert.AreEqual("0", sliderElement1.Text);
        }
        public void SendModifierWindowsKey()
        {
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", "Root");
            WindowsDriver <WindowsElement> desktopSession = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);

            Assert.IsNotNull(desktopSession);

            // Launch action center using Window Keys + A
            editBox.SendKeys(OpenQA.Selenium.Keys.Command + "a" + OpenQA.Selenium.Keys.Command);
            WindowsElement actionCenterElement = null;

            // Before Windows 10 Anniversary and Creators Update Action Center name had lower case c for "center"
            try
            {
                actionCenterElement = desktopSession.FindElementByName("Action Center");
            }
            catch
            {
                actionCenterElement = desktopSession.FindElementByName("Action center");
            }

            Assert.IsNotNull(actionCenterElement);

            // Dismiss action center and cleanup the temporary session
            actionCenterElement.SendKeys(OpenQA.Selenium.Keys.Escape);
            editBox.Click();
            desktopSession.Quit();
        }
Beispiel #23
0
        /// <summary>
        /// Sets the name of the alarm being edited.
        /// </summary>
        /// <param name="name">
        /// The name to set the alarm to.
        /// </param>
        /// <returns>
        /// The <see cref="EditAlarmPage"/>.
        /// </returns>
        public EditAlarmPage SetAlarmName(string name)
        {
            WindowsElement textBox = this.WindowsApp.FindElement(this.alarmNameTextBox);

            textBox.Click();
            textBox.SendKeys(name);
            return(this);
        }
        public void ExcludeApps()
        {
            WindowsElement input = session.FindElementByXPath("//Edit[contains(@Name, \"exclude\")]");

            Assert.IsNotNull(input);
            ClearInput(input);

            string inputValue;

            //valid
            inputValue = "Notepad\nChrome";
            input.SendKeys(inputValue);
            SaveChanges();
            ClearInput(input);
            WaitSeconds(1);
            Assert.AreEqual(inputValue, GetPropertyValue <string>("fancyzones_excluded_apps"));

            //invalid
            inputValue = "Notepad Chrome";
            input.SendKeys(inputValue);
            SaveChanges();
            ClearInput(input);
            WaitSeconds(1);
            Assert.AreEqual(inputValue, GetPropertyValue <string>("fancyzones_excluded_apps"));

            inputValue = "Notepad,Chrome";
            input.SendKeys(inputValue);
            SaveChanges();
            ClearInput(input);
            WaitSeconds(1);
            Assert.AreEqual(inputValue, GetPropertyValue <string>("fancyzones_excluded_apps"));

            inputValue = "Note*";
            input.SendKeys(inputValue);
            SaveChanges();
            ClearInput(input);
            WaitSeconds(1);
            Assert.AreEqual(inputValue, GetPropertyValue <string>("fancyzones_excluded_apps"));

            inputValue = "Кириллица";
            input.SendKeys(inputValue);
            SaveChanges();
            ClearInput(input);
            WaitSeconds(1);
            Assert.AreEqual(inputValue, GetPropertyValue <string>("fancyzones_excluded_apps"));
        }
Beispiel #25
0
 public void PrintItOut()
 {
     tb_a.SendKeys("10");
     tb_b.SendKeys("2");
     btn_Go.Click();
     Assert.AreEqual(5, Convert.ToInt32(lb_Result.Text));
     //Assert.Fail(k.ToString());
 }
        public void CreateSessionWithWorkingDirectoryAndArguments()
        {
            // Use File Explorer to get the temporary folder full path
            secondarySession = Utility.CreateNewSession(CommonTestSettings.ExplorerAppId);
            secondarySession.Keyboard.SendKeys(Keys.Alt + "d" + Keys.Alt + CommonTestSettings.TestFolderLocation + Keys.Enter);
            Thread.Sleep(TimeSpan.FromSeconds(2));
            secondarySession.Keyboard.SendKeys(Keys.Alt + "d" + Keys.Alt); // Select the address edit box using Alt + d shortcut
            string tempFolderFullPath = secondarySession.SwitchTo().ActiveElement().Text;

            Assert.IsFalse(string.IsNullOrEmpty(tempFolderFullPath));

            // Launch Notepad with a filename argument and temporary folder path as the working directory
            DesiredCapabilities appCapabilities = new DesiredCapabilities();

            appCapabilities.SetCapability("app", CommonTestSettings.NotepadAppId);
            appCapabilities.SetCapability("appArguments", CommonTestSettings.TestFileName);
            appCapabilities.SetCapability("appWorkingDir", tempFolderFullPath);
            session = new WindowsDriver <WindowsElement>(new Uri(CommonTestSettings.WindowsApplicationDriverUrl), appCapabilities);
            Assert.IsNotNull(session);
            Assert.IsNotNull(session.SessionId);

            try
            {
                // Verify that Notepad file not found dialog is displayed and save it
                var notFoundDialog = session.FindElementByName("Notepad");
                Assert.AreEqual("ControlType.Window", notFoundDialog.TagName);
                notFoundDialog.FindElementByName("Yes").Click();
            }
            catch
            {
                // Verify that the window title matches the filename if somehow a leftover test file exists from previous incomplete test run
                Assert.IsTrue(session.Title.Contains(CommonTestSettings.TestFileName));
            }

            session.Quit();
            session = null;

            // Verify that the file is indeed saved in the working directory and delete it
            secondarySession.FindElementByAccessibilityId("SearchEditBox").SendKeys(CommonTestSettings.TestFileName + Keys.Enter);
            Thread.Sleep(TimeSpan.FromSeconds(2));
            WindowsElement testFileEntry = null;

            try
            {
                testFileEntry = secondarySession.FindElementByName("Items View").FindElementByName(CommonTestSettings.TestFileName + ".txt") as WindowsElement;  // In case extension is added automatically
            }
            catch
            {
                testFileEntry = secondarySession.FindElementByName("Items View").FindElementByName(CommonTestSettings.TestFileName) as WindowsElement;
            }

            Assert.IsNotNull(testFileEntry);
            testFileEntry.Click();
            testFileEntry.SendKeys(Keys.Delete);
            Thread.Sleep(TimeSpan.FromSeconds(1));
        }
Beispiel #27
0
        public MainWindow MoveMouseToCountryByName(string countryName)
        {
            WindowsElement inputSearch = Session.FindElementByAccessibilityId("SearchInput");

            inputSearch.SendKeys(countryName);
            WindowsElement countryBox = Session.FindElementByName(countryName);

            MoveToElement(countryBox);
            return(this);
        }
Beispiel #28
0
        public void CopyText_CopiesFromTextBoxToLabel()
        {
            WindowsElement textbox        = session.FindElementByAccessibilityId("textBox");
            WindowsElement copyTextButton = session.FindElementByAccessibilityId("copyTextButton");
            WindowsElement label          = session.FindElementByAccessibilityId("label");

            Assert.IsNotNull(textbox);
            Assert.IsNotNull(copyTextButton);
            Assert.IsNotNull(label);

            string testData = "Test123Test123";

            // Select all text and delete to clear the edit box
            textbox.SendKeys(Keys.Control + "a");
            textbox.SendKeys(Keys.Delete);
            textbox.SendKeys(testData);
            copyTextButton.Click();

            Assert.IsTrue(label.Text.Equals(testData));
        }
Beispiel #29
0
        public void Test(String input, String[] output)
        {
            WindowsElement inputBox  = _session.FindElementByAccessibilityId("InputBox");
            WindowsElement outputBox = _session.FindElementByAccessibilityId("OutputBox");

            inputBox.SendKeys(input);
            var elements = outputBox.FindElementsByXPath("//ListItem")
                           .Select(element => element.Text);

            Assert.AreEqual(output, elements);
        }
Beispiel #30
0
        public override void TestInit()
        {
            // Open new alarm page if app is currently in different view
            try
            {
                alarmNameTextBox = session.FindElementByAccessibilityId("AlarmNameTextBox");
            }
            catch
            {
                base.TestInit();
                alarmTabElement.FindElementByAccessibilityId("AddAlarmButton").Click();
                Thread.Sleep(TimeSpan.FromSeconds(1.5));
                alarmNameTextBox = session.FindElementByAccessibilityId("AlarmNameTextBox");
            }

            // Select all text and delete using keyboard shortcut Ctrl + A and Delete
            alarmNameTextBox.SendKeys(Keys.Control + "a");
            alarmNameTextBox.SendKeys(Keys.Delete);
            Assert.AreEqual(string.Empty, alarmNameTextBox.Text);
        }