Ask a Question

Converting a recorded script to Connect C#

SOLVED
bistritapcv
Contributor

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");

8 REPLIES 8
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");
}

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

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.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Yes it is Test Complete.  Using visual studio, I use Connect to connect to test complete, and then write C# code to be executed in TestComplete.  So it is C# code in Visual Studio connecting to test complete.

 

Still new to this, so I used Test Complete recording tool to record my test.  Now I have a C# method I want to take the recorded script into, and have it execute.  But I can't take it verbatim.

Right... it doesn't work quite that way.  You can't just run straight C# code in TestComplete.  TestComplete has a C#Script that is more of an adaptation of JScript.   So, if you want to run a records script from VisualStudio, you should look into this.

https://support.smartbear.com/testcomplete/docs/working-with/integration/ms-vs/alm/run-from-vs.html?...


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

Looks like that requires Test Complete 14 and we are stuck with 12 ;-(

The online versions of the documentation represent the latest version.  If you go into the tool itself and find the same folder/documentation, the instructions there should work just as well with TC 12

 


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available

running automation from visual studio help.png


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: