This project is read-only.

Problem when SetText is greater than the max length of an input field

May 9, 2013 at 6:52 PM
I get this error when I set in an input field with max length of 20 a string of length of 21.

{"Exception from HRESULT: 0xF004F006"}
Cannot perform 'SetProperty of Text with value "Blackobrsotributionol"' on the control. Additional Details:
TechnologyName: 'Web'
ControlType: 'Edit'
Id: 'ctl00_contentBody_fvBeneficiary_ucClaimBeneficiaryControlInsert_tbLastName'
Name: 'ctl00$contentBody$fvBeneficiary$ucClaimBeneficiaryControlInsert$tbLastName'
TagName: 'INPUT'
{ControlType [Edit] ClassName [HtmlTextBox] TagName [INPUT], UniqueIdentifier [34] Id [ctl00_contentBody_fvBeneficiary_ucClaimBeneficiaryControlInsert_tbLastName] Name [ctl00$contentBody$fvBeneficiary$ucClaimBeneficiaryControlInsert$tbLastName]}

Any help ?

May 9, 2013 at 9:46 PM
If this isn't the expected behavior, what else did you expect to happen?

Can you share your HTML and test code please?
May 9, 2013 at 9:50 PM
This is the scenario:

a input textbox with maxlength=10

use SetText with a string "12345678901"

The idea of the test is test that saves only "1234567890" , but CUITe throws error .. and with masked inputs too.

any idea why?
May 10, 2013 at 6:17 AM
Edited May 10, 2013 at 6:17 AM
Here is some sample code that works:
// Arrange
            using (TempFile tempFile = new TempFile(
        <input id=""input"" type=""text"" maxlength=10 />
                CUITe_BrowserWindow window = new CUITe_BrowserWindow("test");

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

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

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

The solution was found in the archived Coded UI test forum thread here.