Forum Discussion

NicolaFilosa_SE's avatar
NicolaFilosa_SE
Contributor
3 years ago

Open Panel Control with TestComplete

Hello to everyone, I have a little program. I have to check the ethernet connection between my product and the software under test. To do it I have to set the ethernet configuration and to do it I have to open Panel Control -> Network and sharing center -> .... How could I open the Panel Control with TestComplete?

Thanks in advance

Nicola

  • Kitt's avatar
    Kitt
    Regular Contributor

    You could try this cmd to launch Network and Sharing: 

    ncpa.cpl

    all you'd have to do is save that off in a 'networkSharing.bat' file > save it in your Project's Stores/Files folder > then run it from a TestComplete script like so:

    function launchNetworkSharing() {
      var batch = Sys.OleObject("WScript.Shell");  
      var run = batch.Run(Project.Path + "\\Stores\\Files\\networkSharing.bat");
      var networkSharing = Sys.Process("explorer", 2).Window("CabinetWClass", "Network Connections", 1);
      if(networkSharing.Exists)
      { 
        Log.Checkpoint("| Network & Sharing Launched |");
        // do some other stuff if you need to
        networkSharing.Close();
      }
    }

    ** I don't have a Desktop license so I can't tell if TestComplete will be able to find the objects within the Network and Sharing options, but this should at least take care of the how to get to Network & Sharing. 

     

    If TC can't find the objects within, you might be stuck writing your own PoswerShell script or similar, like [this].  

    • NicolaFilosa_SE's avatar
      NicolaFilosa_SE
      Contributor

      Thank you very much for your kindness! We have some TestedApps that are batch files, do you think that I can create a batch file and then launch it? Could it works?

      Thank you very much

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    What OS are you using? What exactly are you configuring or verifying?

     

    I ask, because you might be able to use the Command Prompt to achieve what you need to do.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    TestedApps and batch file is possible, but it all depends on what you are configuring or verifying? There may be standard Windows Commands you can use, or you might have to use PowerShell

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I don't know yet, as you still haven't specified what you are verifying!

     

    The title mentions "opening control panel...".

     

    You mention, "check the ethernet connection between my product and the software under test" - How are you doing this?

     

    Also, you mention, "I have to set the ethernet configuration" - How are you doing this?

     

     

    • NicolaFilosa_SE's avatar
      NicolaFilosa_SE
      Contributor

      Sorry. I have to open Panel Control to set the IP address and the Subnet Mask.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    Now that we know what you are doing, you can use command prompt which is easier to automate. See Set static IP address on Windows 10 from Command Prompt, you can use the command "netsh" and invoke the command and get the output like so,

    function Test()
    {
        var oExec = WshShell.Exec("netsh interface ip set address name=\"Ethernet1\" static 10.1.4.220 255.255.255.0 10.1.4.1");
        while (oExec.Status == 0) {
            aqUtils.Delay(1000);
        }
        while (!oExec.StdOut.AtEndOfStream) {
            Log.Message(oExec.StdOut.ReadLine());
        }
    }