Simulated Manual Typing throws exception when converted to code

2 posts, 0 answers
  1. dan
    dan avatar
    27 posts
    Member since:
    Jun 2016

    Posted 10 Aug Link to this post

    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

  2. Boyan Boev
    Admin
    Boyan Boev avatar
    1040 posts

    Posted 15 Aug Link to this post

    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!
Back to Top