Forum Discussion

layfonchian's avatar
layfonchian
New Contributor
10 years ago

How to open internet explorer using C# application

I have done the debug on test complete

 

right now i would like to port over to my C# application to run.

 

Can i know what is the command to open internet explorer in C# application? i am still very new on test complete

 

Test Complete C# script

 

var browser;
var DestinationFileName="C:\\Share\\EIMSInterBuildingTransfer.xlsx";
browser=Browsers["Item"](btIExplorer)["Run"]("http://example.com");

 

Aliases["browser"]["pageHttpPgftmt20nlbPngIntelComIc"]["RootBrowserWindow"]["CatchuiNewui"]["Grid"]["TabControl"]["WPFObject"]("ReportsTabItem")["Click"]();

 

 

What is the C# script to open internet explorer? i tested below script and it prompt error

 

var browser = Connect.TestedApps["AddBrowser"]("Internet Explorer");
var app = Connect.TestedApps["Items"](browser);
app["PageAddress"] = "http://example.com";
app["Run"]();
Connect.Aliases["browser"]["pageHttpPgftmt20nlbPngIntelComIc"]["RootBrowserWindow"]["CatchuiNewui"]["Grid"]["TabControl"]["WPFObject"]("ReportsTabItem")["Click"]();

 

Is there any good tutorial guide for C# port script?

6 Replies

  • Hi layfonchian,

     

    To run Internet Explorer from a C# Connected App, you can use:

    Connect.Integration["GetObjectByName"]("Browsers")["Item"]("iexplore")["Run"]("http://example.com");

    Though your TestedApps variant is also valid.

     

    Two notes:

    1) For the Connect calls to work, TestComplete must be running a test at the same time. You have two options:

    • Launch a dummy TestComplete test from your Connected App, before any Connect calls:
    • Connect.RunTest("My Test", "MyProject", "C:\\Work\\DummyProject.pjs");
    • Launch your Connected App from a wrapper TestComplete test.

    For details, please see Creating Connected Applications in C#, sections "Writing Test Code in C# Connected Applications" and "Writing Code in TestComplete Projects".

     

    2) On Windows 10, 8.x and 2012, you may need to configure the manifest for your C# Connected App and/or TestComplete. More information here.

     

    Hope this helps! If you are still having issues, please open a support ticket with out technical support.

    • layfonchian's avatar
      layfonchian
      New Contributor

      Hi,

       

      I tried to execute your solution and it prompt out empty messagebox with "Cannot create object" 

       

      Screenshot 

       

       

      Here is my code snippet

       

      using AutomatedQA.script;
      using AutomatedQA.TestComplete;

      public static void Testing123()
      {

       

      Connect.RunTest("MyTest", "Testing", "C:\\Users\\ABC\\Documents\\TestComplete 11 Projects\\Testing\\Testing.pjs");
      var browser = Connect.Integration["GetObjectByName"]("Browsers")["Item"]("iexplore")["Run"]("http://example.com");

       }

      Testing.pjs is just a dummy TestComplete project

  • Hi

     

    If you want to open Internet explorer using script please see example below

     

    // Open smartbear.com in Chrome browser:
    Browsers["Item"](btChrome)["Run"]("http://example.com");

     

    Regards

    Damien

    • layfonchian's avatar
      layfonchian
      New Contributor

      Hi,

       

      Thanks for your reply

       

      But i am not trying to open internet explorer using test complete.

       

      I am trying to open it via our normal C# application 

       

      using AutomatedQA.script;
      using AutomatedQA.TestComplete;

      void Test()
      {
        var p, w;
        p = Sys["Process"]("notepad");
        w = p["Window"]("Notepad", "*");
        w["Activate"]();
        w["Window"]("Edit")["VScroll"]["Pos"] = 0;
        w["Window"]("Edit")["Click"](9, 9);
        Sys["Keys"]("Test");
        w["MainMenu"]["Click"]("File|Exit");
      }

       

       

      https://support.smartbear.com/viewarticle/71543/

      • DWalsh's avatar
        DWalsh
        Icon for Staff rankStaff

        Hi

         

        Please log a ticket with support and they will provide additional feedback so to where the issue may be occuring.

         

        Kind Regards

        Damien