예제 #1
0
        public void SetText_OnHtmlEdit_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div id=""div1"">
            <input type=""text""/>
        </div>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var              window       = new WebPage("test");
                EnhancedHtmlDiv  div          = window.Get <EnhancedHtmlDiv>("id=div1");
                EnhancedHtmlEdit inputTextBox = div.Get <EnhancedHtmlEdit>();

                //Act
                inputTextBox.SetText("text");

                //Assert
                Assert.AreEqual("text", inputTextBox.GetText());

                window.Close();
            }
        }
예제 #2
0
        public void SetText_OnHtmlEditWithOverlappedDiv_Succeeds()
        {
            //Arrange
            using (var tempFile = new TempFile(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <div class=""textbox"" id=""idDiv_PWD_UsernameTb"" style=""margin-bottom: 8px;"">
            <div style=""width: 100%; position: relative;"">
                <input name=""login"" id=""i0116"" style=""ime-mode: inactive;"" type=""email"" maxLength=""113""/>
                <div class=""phholder"" style=""left: 0px; top: 0px; width: 100%; position: absolute; z-index: 5;"">
                    <div class=""placeholder"" id=""idDiv_PWD_UsernameExample"" style=""cursor: text;"">
                    Text - [email protected]
                    </div>
                </div>
            </div>
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var bWin = new WebPage("test");
                EnhancedHtmlEdit txtUserName = bWin.Get <EnhancedHtmlEdit>("id=i0116");

                //Act
                txtUserName.SetText("hello");

                //Assert
                Assert.AreEqual("hello", txtUserName.GetText());

                bWin.Close();
            }
        }
예제 #3
0
        public void Launch_TempHtmlFileWithInputWithMaxLength_CanSetTextWhichExceedsMaxLength()
        {
            // Arrange
            using (var tempFile = new TempFile(
                       @"<html>
    <head>
        <title>test</title>
    </head>
    <body>
        <input id=""input"" type=""text"" maxlength=10 />
    </body>
</html>"))
            {
                WebPage.Launch(tempFile.FilePath);
                var window = new WebPage("test");

                EnhancedHtmlEdit input = window.Get <EnhancedHtmlEdit>("id=input");

                // Act
                string inputText  = "12345678901";
                string outputText = "1234567890";
                Keyboard.SendKeys(input.UnWrap(), inputText);

                // Assert
                Assert.AreEqual(input.GetText(), outputText);

                window.Close();
            }
        }