This is a migrated thread and some comments may be shown as answers.

System.ArgumentException: Invalid input type 'Text' for this control. Control was expecting 'Email'

5 Answers 211 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
Veteran
Iron
William asked on 29 Mar 2021, 10:10 PM

Hi Guys,

I am getting this error when I run convert recorded steps to Code.

Please refer video.

 

Code :

  Actions.SetText(Pages.Time2Work.TbUsernameEmail, "AutoCycle");

 

Failure Information: 
~~~~~~~~~~~~~~~
Exception thrown executing coded step: 'Enter text 'AutoCycle' in 'TbUsernameEmail''.
InnerException:
System.ArgumentException: Invalid input type 'Text' for this control. Control was expecting 'Email'
   at ArtOfTest.WebAii.Controls.Control.CreateInstance[TControl](Element e, Boolean throwIfNull)
   at ArtOfTest.WebAii.ObjectModel.Element.As[TControl]()
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get[TControl](HtmlFindExpression expr)
   at ArtOfTest.WebAii.TestTemplates.HtmlElementContainer.Get[TControl](String[] clauses)
   at WebTest.Pages.Time2WorkPage.get_TbUsernameEmail() in c:\Dev\OnTime\Scheduler\WebTests\System Regression\Pages.g.cs:line 364
   at WebTest.Login_Employee_User.Login_Employee_User_CodedStep3() in c:\Dev\OnTime\Scheduler\WebTests\System Regression\03_User Tests\Login Employee User.tstest.cs:line 148

5 Answers, 1 is accepted

Sort by
0
Plamen Mitrev
Telerik team
answered on 30 Mar 2021, 11:23 AM

Hello William,

Thank you for sharing details about the encountered troubles with the execution.

It looks like the input field expects a certain input or there are events that need to be triggered. You can try to simulate the real user actions by enabling the "SimulateRealTyping" on the original recorded step 3 (see simulateRealTyping.png). That will actually invoke a series of actions that replicate the user actions, like:

- set the focus on the target element;
- click inside the input field;
- send individual keyboard actions for each character of the string.

Please give that a try and let me know what is the behavior. If you continue to experience any troubles, please share the .tstest and .tstest.cs files of your test, along with the exported step failure details. I will review that information and provide further guidance.

Regards,
Plamen Mitrev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
0
William
Top achievements
Rank 1
Veteran
Iron
answered on 31 Mar 2021, 12:38 AM

Hello Plamen Mitrev,

Thank you so much for your response.

I am still experiencing same issue after enabling 'SimulateRealTyping' on recorded steps and then converted to code.

I have attached failure details and test file.

 

0
Plamen Mitrev
Telerik team
answered on 01 Apr 2021, 01:24 PM

Hello William,

Thank you for testing the provided suggestion and gathering the requested details. I analyzed them and I have an idea what might have happened and how you can configure the test. Please find more details in the bullets below.

I assume that the input field for the email in your application has changed, because initially the element was recorded as HtmlInputEmail and it is now HtmlInputText. As result, the "TbUsernameEmail" element's ControlType is the still and HtmlInputEmail and the execution of the coded step is not able to match that to the actual element type in the DOM tree (see inputTypeInDOM.png and elementControlTypeOriginalTest.png).

Since the input field now expect text, not email, you have two options to configure your test.

  1. Change the ControlType of the target element "TbUsernameEmail" to HtmlInputText to match the current state of the application under test. This will not immediately fix the execution of the coded step and if you need to run this code in a coded step rather than the recorded step 3, you need to close all web test and restart Test Studio. That will refresh the references and ControlType that of the changed element.
  2. Delete the current web test and create new one. Record the necessary steps to login the application. Once you do that, check the ControlType of the target element to see if it matches the input type in the application. I created a local application with the same input element from you application and entered a test email there. The steps and ControlType was recorded as expected and the converted step to code was also working as expected (see elementControlTypeLocalPage.png).

Please check with the developers of the application if the input type was changed recently and if it should be "text" or "email". Test the above suggestions and let me know if that helped you resolve the issue with the execution.

I remain available to provide further assistance if you experience any troubles or you have follow up questions.

Regards,
Plamen Mitrev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
0
William
Top achievements
Rank 1
Veteran
Iron
answered on 13 Apr 2021, 11:56 PM

Thank you so much Plamen Mitrev. It worked when I changed control type from 'Email' to 'Text' and also try recording that element and verified that it is 'HtmlInputText'.

Sorry for delay. Thank you so much once again for helping me out! I am very happy now. All my tests are running smoothly. 

 

0
Plamen Mitrev
Telerik team
answered on 14 Apr 2021, 03:34 PM

Hello William,

I am happy to know that the issue is resolve and your tests are working. The newly recorded steps are also captured with the correct control type and work as expected, which is great.

Thank you for your follow up. Have a great day ahead!

Regards,
Plamen Mitrev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Test Studio course! Check it out at https://learn.telerik.com/.
Tags
General Discussions
Asked by
William
Top achievements
Rank 1
Veteran
Iron
Answers by
Plamen Mitrev
Telerik team
William
Top achievements
Rank 1
Veteran
Iron
Share this question
or