Beispiel #1
0
        public void ScrollAndClick <T>(UITestControl parent, PropertyType type, string typeC) where T : HtmlControl
        {
            HtmlControl control = (T)Activator.CreateInstance(typeof(T), new object[] { parent });

            AddPropertyControl(control, type, typeC);

            bool isClickable = false;

            if (control.TryFind())
            {
                while (!isClickable)
                {
                    try
                    {
                        control.EnsureClickable();
                        Mouse.Click(control);
                        isClickable = true;
                    }
                    catch (FailedToPerformActionOnHiddenControlException)
                    {
                        Mouse.MoveScrollWheel(-1);
                        throw;
                    }
                }
            }
            else
            {
                throw new AssertInconclusiveException("Control Not Found");
            }
        }
        public bool IsValidationDisplayed()
        {
            var uiValidationError = new HtmlControl(browser);

            uiValidationError.SearchProperties.Add(HtmlControl.PropertyNames.Id, EditWorkItemPageConst.EDIT_TITLE_VALIDATION_ID_ERROR);

            return(uiValidationError.TryFind());
        }
Beispiel #3
0
        public bool IsValidationDisplayedForNote()
        {
            var uiValidationError = new HtmlControl(browser);

            uiValidationError.SearchProperties.Add(HtmlControl.PropertyNames.Id, AddDailyPlanPageConst.ADD_NOTE_TEXT_ERROR_ID);

            return(uiValidationError.TryFind());
        }
Beispiel #4
0
        public bool IsValidationDisplayedForSelectDayBeforeWorkItems()
        {
            var uiValidationError = new HtmlControl(browser);

            uiValidationError.SearchProperties.Add(HtmlControl.PropertyNames.Id, AddDailyPlanPageConst.SELECT_DAILY_PLAN_DAY_BEFORE_TEXT_ERROR_ID);

            return(uiValidationError.TryFind());
        }
        public bool IsValidationDisplayed()
        {
            var uiValidationError = new HtmlControl(browser);

            uiValidationError.SearchProperties.Add(HtmlControl.PropertyNames.Id, AddProjectPageConst.ADD_TITLE_TEXTBOX_ID_ERROR);

            return(uiValidationError.TryFind());
        }
Beispiel #6
0
        private static HtmlDocument AcceptConsent(BrowserWindow browser, HtmlDocument page)
        {
            HtmlControl acceptConsentButton = new HtmlControl(page);

            acceptConsentButton.SearchProperties[HtmlEdit.PropertyNames.Id] = "cred_accept_button";
            acceptConsentButton.TryFind();
            if (acceptConsentButton.Exists)
            {
                Mouse.Click(acceptConsentButton);
            }

            // Get the new page
            page = new HtmlDocument(browser);
            return(page);
        }
Beispiel #7
0
        private static HtmlDocument EnterCredentialsAndSignIn(BrowserWindow browser, HtmlDocument page, string login, string password)
        {
            // Check if there is a login user chooser (some identity already logged-in)
            HtmlControl loginUserChooser = new HtmlControl(page);

            loginUserChooser.SearchProperties[HtmlEdit.PropertyNames.Id] = "login_user_chooser";
            loginUserChooser.TryFind();
            if (loginUserChooser.Exists)
            {
                HtmlTable chooseAnotherAccount = new HtmlTable(loginUserChooser);
                chooseAnotherAccount.SearchProperties[HtmlTable.PropertyNames.Id] = "use_another_account";
                chooseAnotherAccount.TryFind();
                if (chooseAnotherAccount.Exists)
                {
                    Mouse.Click(chooseAnotherAccount);
                }
            }

            // Enter the login and password
            HtmlEdit loginTextBox = new HtmlEdit(page);

            loginTextBox.SearchProperties[HtmlEdit.PropertyNames.Id] = "cred_userid_inputtext";
            loginTextBox.Text = login;
            loginTextBox.WaitForControlReady();

            // The page can be refreshed.
            page = new HtmlDocument(browser);

            HtmlEdit passwordTextBox = new HtmlEdit(page);

            passwordTextBox.SearchProperties[HtmlEdit.PropertyNames.Id] = "cred_password_inputtext";
            passwordTextBox.EnsureClickable();
            passwordTextBox.Password = password;

            HtmlControl signInButton = new HtmlControl(page);

            signInButton.SearchProperties[HtmlControl.PropertyNames.Id] = "cred_sign_in_button";
            Mouse.Click(signInButton);

            // Get the new page
            page = new HtmlDocument(browser);
            return(page);
        }
        public void WebTest_TestForm()
        {
            var browserIdentifier = "IE";

            if (TestContext.DataRow != null)
            {
                browserIdentifier = TestContext.DataRow[0].ToString();
            }
            BrowserWindow.CurrentBrowser = browserIdentifier;
            BrowserWindow browser = BrowserWindow.Launch(new Uri(StartUrl));

            var nameTextBox = new HtmlEdit(browser);

            nameTextBox.SearchProperties.Add(HtmlControl.PropertyNames.Id, "Name");
            nameTextBox.Text = "Some Name";

            var submitButton = new HtmlButton(browser);

            submitButton.SearchProperties.Add(HtmlButton.PropertyNames.Type, "submit");
            Mouse.Click(submitButton);

            var header = new HtmlControl(browser);

            header.SearchProperties.Add(HtmlControl.PropertyNames.Id, "addCustomerHeader");
            Assert.IsTrue(header.TryFind());

            var nameValidationmessage = new HtmlSpan(browser);

            nameValidationmessage.SearchProperties.Add(HtmlControl.PropertyNames.Id, "Name-error");
            Assert.IsFalse(nameValidationmessage.TryFind());

            var expectedEmailvalidationMessage = string.Format(Messages.FieldRequired, Labels.EmailAddress);
            var emailAddessValidationMessage   = new HtmlSpan(browser);

            emailAddessValidationMessage.SearchProperties.Add(HtmlControl.PropertyNames.Class, "field-validation-error");
            emailAddessValidationMessage.SearchProperties.Add(HtmlControl.PropertyNames.InnerText, expectedEmailvalidationMessage, PropertyExpressionOperator.Contains);

            Assert.IsTrue(emailAddessValidationMessage.TryFind());
            Assert.IsTrue(emailAddessValidationMessage.InnerText.Equals(expectedEmailvalidationMessage));
        }