public void PasswordTests()
        {
            HtmlDiv bodyContainerDiv = new HtmlDiv(this.window);

            bodyContainerDiv.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "layoutBodyContainer");

            // no fieldset available
            HtmlControl fieldset = new HtmlCustom(bodyContainerDiv);

            fieldset.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "fieldset");

            HtmlEdit passwordInput = new HtmlEdit(fieldset);

            passwordInput.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "passwordInput");

            Assert.IsTrue(passwordInput.TryFind());

            try
            {
                passwordInput.EnsureClickable();
            }
            catch { }

            Point p;

            Assert.IsTrue(passwordInput.TryGetClickablePoint(out p), "There should be a point on screen for the disabled input.");


            passwordInput.Text = "myPassword";
        }
Ejemplo n.º 2
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 TestDisabledInput()
        {
            HtmlDiv bodyContainerDiv = new HtmlDiv(this.window);

            bodyContainerDiv.SearchProperties.Add(HtmlDiv.PropertyNames.Id, "layoutBodyContainer");

            // no fieldset available
            HtmlControl fieldset = new HtmlCustom(bodyContainerDiv);

            fieldset.SearchProperties.Add(HtmlControl.PropertyNames.TagName, "fieldset");

            HtmlEdit disabledInput = new HtmlEdit(fieldset);

            disabledInput.SearchProperties.Add(HtmlEdit.PropertyNames.Id, "disabledInput");

            Assert.IsTrue(disabledInput.TryFind(), "Disabled text box should be able to be found.");

            try
            {
                disabledInput.EnsureClickable();
            }
            catch { }

            Point p;

            Assert.IsTrue(disabledInput.TryGetClickablePoint(out p), "There should be a point on screen for the disabled input.");

            Assert.IsFalse(disabledInput.Enabled);

            Assert.IsTrue(StringComparer.OrdinalIgnoreCase.Equals("testValue", disabledInput.Text));

            try
            {
                disabledInput.Text = "Other Value";
                Assert.Fail("Attempting to set text of a disabled input should throw an exception.");
            }
            catch (ActionNotSupportedOnDisabledControlException)
            {
            }

            Assert.IsTrue(StringComparer.OrdinalIgnoreCase.Equals("testValue", disabledInput.Text));
        }