System.Runtime.InteropServices.COMException: Could not complete the operation due to error 80020101.

Mar 28, 2013 at 8:11 AM
Edited Mar 29, 2013 at 11:11 AM
Hi CUITe Team

I am trying to use Telerik Control but your given example is giving me below error. I am not doing anything new and just copy pasted the example given by you for Telerik Controls.

Test Name: telerik_demo
Test FullName: d:\cuite_solution\mercury_tours\telerik_demo.orderedtest
Test Source: d:\cuite_solution\mercury_tours\telerik_demo.orderedtest : line -1
Test Outcome: Failed
Test Duration: 0:00:36.1865048

Result1 Name: 3- FillProduct (telerik_demo)
Result1 Outcome: Failed
Result1 Duration: 0:00:00.5591315
Result1 Message:
Test method Mercury_Tours.Web.Telerik.Test_Methods.Demo.FillProduct threw exception:
System.Runtime.InteropServices.COMException: Could not complete the operation due to error 80020101.
Result1 StackTrace:
at System.Dynamic.ComRuntimeHelpers.CheckThrowException(Int32 hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)
at CallSite.Target(Closure , CallSite , ComObject , String )
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at CallSite.Target(Closure , CallSite , Object , String )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid2[T0,T1](CallSite site, T0 arg0, T1 arg1)
at CUITe.Browsers.InternetExplorer.RunScript(BrowserWindow browserWindow, String code) in d:\CUITe_Code\CUITe\Browsers\InternetExplorer.cs:line 32
at CUITe.Controls.HtmlControls.CUITe_BrowserWindow.RunScript(String code) in d:\CUITe_Code\CUITe\Controls\HtmlControls\CUITe_BrowserWindow.cs:line 183
at CUITe.Controls.TelerikControls.Telerik_ComboBox.SelectItemByText(String sText, Int32 milliseconds) in d:\CUITe_Code\CUITe\Controls\TelerikControls\Telerik_ComboBox.cs:line 23
at Mercury_Tours.Web.Telerik.Test_Methods.Demo.FillProduct() in d:\CUITe_Solution\Mercury_Tours\Web\Telerik\Test_Methods\Demo.cs:line 42

The Ghost
Mar 30, 2013 at 9:53 PM

Unfortunately, support for Telerik controls was not tested that often and it had been broken for some time.

I went ahead and updated the Telerik ASP.NET ComboBox integration test and object repository class to fix the issues.
        public void SetText_OnTelerikASPNETComboBox_SelectsItemByText()
            DemosOfTeleriksASPNETComboBoxControl window = CUITe_BrowserWindow.Launch<DemosOfTeleriksASPNETComboBoxControl>(
            Keyboard.SendKeys("{Tab}"); // close drop down menu
            window.Region.SetText("Bloomfield Hills");
            Keyboard.SendKeys("{Tab}"); // close drop down menu
            window.Dealer.SetText("Exotic Liquids");
            Keyboard.SendKeys("{Tab}"); // close drop down menu
            window.PaymentMethod.Click(); // America Express
            Keyboard.SendKeys("{Down}"); // MasterCard
            Keyboard.SendKeys("{Down}"); // Visa
            Keyboard.SendKeys("{Tab}"); // close drop down menu
Mar 31, 2013 at 11:46 PM
Thanks icnocop

so you are treating combobox as text box in below code. I have seen that Coded UI is able to identify Telerik Controls as HTML Controls. What do you suggest should we automate them with HTMLControls namespace or should we write separate namespace for Telerik Controls? Another question that is execution of javascript or jquery scripts give 100% success all time or it may fail.


Apr 1, 2013 at 2:36 AM
Edited Apr 1, 2013 at 2:40 AM
Hi Sudhish,

The reason I am treating Telerik's ASP.NET RadComboBox as an edit control is because that is how it is rendered in html:

<input type="text" value="Choose a Product" id="ctl00_ContentPlaceHolder1_RadComboBoxProduct_Input" class="rcbInput radPreventDecorate rcbEmptyMessage" name="ctl00$ContentPlaceHolder1$RadComboBoxProduct">

I went ahead and updated the code to resolve the issue using the Telerik_ComboBox control.
    public class DemosOfTeleriksASPNETComboBoxControl : CUITe_BrowserWindow
        public new string sWindowTitle = "Demos of Telerik's ASP.NET ComboBox control";

        public Telerik_ComboBox cbProduct { get { return Get<Telerik_ComboBox>("id=ctl00_ContentPlaceHolder1_RadComboBoxProduct"); } }
        public Telerik_ComboBox cbRegion { get { return Get<Telerik_ComboBox>("id~ctl00_ContentPlaceHolder1_RadComboBoxRegion"); } }
        public Telerik_ComboBox cbDealer { get { return Get<Telerik_ComboBox>("id~ctl00_ContentPlaceHolder1_RadComboBoxDealer"); } }
        public Telerik_ComboBox cbPaymentMethod { get { return Get<Telerik_ComboBox>("id~ctl00_ContentPlaceHolder1_RadComboBoxPaymentMethod"); } }

        public void SelectItemByText_OnTelerikASPNETComboBox_Succeeds()
            DemosOfTeleriksASPNETComboBoxControl pgPage = CUITe_BrowserWindow.Launch<DemosOfTeleriksASPNETComboBoxControl>(
            pgPage.cbProduct.SelectItemByText("Tofu", 5000);
            pgPage.cbRegion.SelectItemByText("Bloomfield Hills", 5000);
            pgPage.cbDealer.SelectItemByText("Exotic Liquids", 5000);
            pgPage.cbPaymentMethod.SelectItemByText("American Express", 5000);
The Telerik ASP.NET ComboBox wrapper control code is fragile because:
  1. It uses a third party web page for testing
  2. The JavaScript code is different for different versions of the Telerik ASP.NET ComboBox, which I am not exactly sure which JavaScript works with which.
I think the Telerik control wrappers should have a different namespace.

Execution of JavaScript has only been tested with InternetExplorer and it should work all the time as long as the JavaScript being executed does not throw an exception. If it does, then as you noticed, the following .NET exception is raised: System.Runtime.InteropServices.COMException: Could not complete the operation due to error 80020101.

It seems Telerik has since updated their API so that the showDropDown() JavaScript method was replaced with toggleDropDown() or similar and that is why exceptions were thrown.
Apr 1, 2013 at 6:16 AM
Thanks icnocop

I am getting below error now:
System.NullReferenceException: Object reference not set to an instance of an object.

It is coming because We have not set _window object anywhere and we are using this object to run RunScript() method in Telerik_ComboBox class. We have SetWindow() method in Telerik_ComboBox class but we have never called it anywhere due to which _window is referring to null.

The Ghost
Apr 1, 2013 at 6:57 AM
Hi Sudhish,

You'll need to download, build, and reference the latest source code from changeset 25237.