Forum Discussion

bistritapcv's avatar
bistritapcv
Contributor
6 years ago

Converting a recorded script to Connect C#

Hello

 

I successfully recorded (as a script) and played back my test.  I have a small part of the script below.  Not sure what language the script is in.

 

I have to convert this to C# using Connect.  Not sure how to do that.  As I suspected, I can't just copy verbatim.  Wondering whether you could help me with a small part of the test.  Then maybe I can figure out how to do all of it.  Rest sassured each variable is declared as "var" in the script.  I just did not copy the var decs.  So does anyone have some tips as how to convert to C#? This is Windows 10 / TC 12, VS 2012.

 

here is a sample.  I know I can do a Connect.Aliases["explorer'] I guess, but then am stuck:

 

explorer = Aliases.explorer;
folderView = explorer.wndProgman.SHELLDLL_DefView.FolderView;
folderView.Drag(396, 494, 6, -3);
NameMapping.Sys.Keys("[Hold][Win]e[Release]");
wndCabinetWClass = explorer.wndCabinetWClass;
wndCabinetWClass.ShellTabWindowClass.DUIViewWndClassName.Explorer_Pane.CtrlNotifySink.NamespaceTreeControl.tvNamespaceTreeControl.ClickItem("|Desktop|This PC|MyCmd");
TestedApps.claim.Run(1, true);
java = Aliases.java;
panel = java.LoginDialog.RootPane.null_layeredPane.null_contentPane.Panel;
textField = panel.TextField;
textField.Click(68, 10);
textField.Keys("MYLOGIN");

  • IStaroverov's avatar
    IStaroverov
    SmartBear Alumni (Retired)

    If I understood correctly, you want to convert to C#Script.

    You could try this code:

    function Test1()
    {
    var explorer = Aliases["explorer"];
    var folderView = explorer["wndProgman"]["SHELLDLL_DefView"]["FolderView"];
    folderView["Drag"](396, 494, 6, -3);
    NameMapping["Sys"]["Keys"]("[Hold][Win]e[Release]");
    var wndCabinetWClass = explorer["wndCabinetWClass"];
    wndCabinetWClass["ShellTabWindowClass"]["DUIViewWndClassName"]["Explorer_Pane"]["CtrlNotifySink"]["NamespaceTreeControl"]["tvNamespaceTreeControl"]["ClickItem"]("|Desktop|This PC|MyCmd");
    TestedApps["claim"]["Run"](1, true);
    var java = Aliases["java"];
    var panel = java["LoginDialog"]["RootPane"]["null_layeredPane"]["null_contentPane"]["Panel"];
    var textField = panel["TextField"];
    textField["Click"](68, 10);
    textField["Keys"]("MYLOGIN");
    }

    • bistritapcv's avatar
      bistritapcv
      Contributor

      I think I need to specify the objects in a library because earlier it couldn't find drag, etc?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Keep in mind, Drag is not an object, it's a method.

         

        Again... what are you trying to do?  What was posted above was converting one script to be executed within TestComplete with another script, also to be executed within TestComplete.  If you are trying to convert this into C# to compile within VisualStudio, that's an ENTIRELY different thing.