System.ArgumentException: Invalid input type

2 posts, 0 answers
  1. clee
    clee avatar
    2 posts
    Member since:
    Aug 2012

    Posted 15 Aug 2012 Link to this post

    Hi, I currently am using a snippet of code similar to this to log into the site under test:

    ActiveBrowser.NavigateTo(url);
    ActiveBrowser.WaitUntilReady();
    username.Text = userName;
    password.Text = password;
    submit.Click();
    ActiveBrowser.WaitUntilReady();

    where username is of type HtmlInputText and password is HtmlInputPassword. When I'm running this, the log in works most of the time. However, I've also been frequently getting this error:

    System.ArgumentException : Invalid input type 'Text' for this control. Control was expecting 'Password'
    at ArtOfTest.WebAii.Controls.Control.CreateInstance(Element e, Boolean throwIfNull)
    at ArtOfTest.WebAii.ObjectModel.Element.As()

    The HTML of the password looks like this:
    <input id="txtPass" name="password" type="text" title="Password">

    However changing the password to HtmlInputText also results in an exception:
    Invalid input type 'Password' for this control. Control was expecting 'Text'

    Does anyone know what could be causing it?
  2. Byron
    Admin
    Byron avatar
    184 posts

    Posted 20 Aug 2012 Link to this post

    Hello Claire,

    Because this issue is intermittent, it is probably a timing issue. It is likely that the target element has not loaded in these cases. To avoid this scenario, I recommend changing your code to wait for the target element to exist. Even though you have called WaitUntilReady(), there may be other events (such as AJAX) that must complete before the target element exists.

    If this does not resolve your issue, we will need more information about your test scenario. Please provide us with a copy of your test and access to your application. Also, please provide your failure log and a copy of the DOM at the time of failure. You can export these to file from the failure tab for your test and add them to a .zip archive. If it is not possible to grant us access to your application, please take a Fiddler trace and attach it to a support ticket in a zip file. If you are unfamiliar with how to do that please refer to this short video. You can download the Fiddler application from here. A Jing video demonstrating the issue may also help us to better understand what is happening. Thanks for providing the information we need to best advise you.
     

    Greetings,
    Byron
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
Back to Top