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

Simulated Manual Typing throws exception when converted to code

1 Answer 55 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
dan
Top achievements
Rank 1
dan asked on 10 Aug 2016, 12:40 PM

Hi ,

I have an input that require simulated manual entry in order to trigger the validation. I selected ;'simulate manual typing' for my recorded step and everything worked fine.

Now, when I convert the recorded step to a coded step, the step fails.

Here's the coded step..

[CodedStep(@"Enter Comment Text 'Automation Test'")]
        public void enter_Address_data_CodedStep3()
        {
            // Enter text 'Automation Test' in 'NewAddressdescriptionTextArea'
            Actions.SetText(Pages.MicrosoftDynamicsCRM.FrameContentIFrame.NewAddressdescriptionTextArea, "");
            Pages.MicrosoftDynamicsCRM.FrameContentIFrame.NewAddressdescriptionTextArea.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementTopAtWindowTop);
            ActiveBrowser.Window.SetFocus();
            Pages.MicrosoftDynamicsCRM.FrameContentIFrame.NewAddressdescriptionTextArea.Focus();
            Pages.MicrosoftDynamicsCRM.FrameContentIFrame.NewAddressdescriptionTextArea.MouseClick();
            Manager.Desktop.KeyBoard.TypeText("Automation Test",50,100,true);
            
        }

 

and the exception...

Failure Information: 
~~~~~~~~~~~~~~~
Exception thrown executing coded step: 'Enter text 'Automation City' in 'CityText''.
InnerException:
ArtOfTest.WebAii.Exceptions.ExecuteCommandException: ExecuteCommand failed!
InError set by the client. Client Error:
System.ArgumentException: Tag collection of 'input' elements is either empty or has less elements than the element occurrence requested. RequestedIndex: '8', ElementLength: '0'
   at ArtOfTest.InternetExplorer.IECommandProcessor.FindElement(ElementIdMessage id)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommandInternal(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)
BrowserCommand (Type:'Action',Info:'NotSet',Action:'SetText',Target:'ElementId (tagName: 'input',occurrenceIndex: '8')',Data:'',ClientId:'Client_fc23a956-34ef-4a07-a35b-70219db7cf85',HasFrames:'False',FramesInfo:'',TargetFrameIndex:'-1',InError:'True',Response:'System.ArgumentException: Tag collection of 'input' elements is either empty or has less elements than the element occurrence requested. RequestedIndex: '8', ElementLength: '0'
   at ArtOfTest.InternetExplorer.IECommandProcessor.FindElement(ElementIdMessage id)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessActionCommands(BrowserCommand request)
   at ArtOfTest.InternetExplorer.IECommandProcessor.ProcessCommandInternal(WebBrowserClass ieInstance, BrowserCommand request, IHTMLDocument2 document)')
InnerException: none.

   at ArtOfTest.WebAii.Core.Browser.ExecuteCommandInternal(BrowserCommand request)
   at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request, Boolean performDomRefresh, Boolean waitUntilReady)
   at ArtOfTest.WebAii.Core.Browser.ExecuteCommand(BrowserCommand request)
   at ArtOfTest.WebAii.Core.Actions.SetText(Element targetElement, String text)
   at ArtOfTest.WebAii.Core.Actions.SetText(Control targetControl, String text)
   at TestProject2.enter_Address_data.enter_Address_data_CodedStep2() in f:\New folder\Test Studio Projects\TestProject2\Address\Steps\enter Address data.tstest.cs:line 239

 

Any help would be appreciated.

 

Thanks,

dan

1 Answer, 1 is accepted

Sort by
0
Boyan Boev
Telerik team
answered on 15 Aug 2016, 08:08 AM
Hi Dan,

Could you please refresh the frame's DOM tree before typing in the input control. Please put this into the coded step as the very first row.

Manager.ActiveBrowser.Frames.RefreshAllDomTrees();

Let me know if that helps.

Regards,
Boyan Boev
Telerik by Progress
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
dan
Top achievements
Rank 1
Answers by
Boyan Boev
Telerik team
Share this question
or