I am getting this error when I run convert recorded steps to Code.
Please refer video.
Exception thrown executing coded step: 'Enter text 'AutoCycle' in 'TbUsernameEmail''.
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.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
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.
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.
- 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.
- 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.
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.
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!