cancel
Showing results for 
Search instead for 
Did you mean: 

Converting a recorded script to Connect C#

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

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Converting a recorded script to Connect C#

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
[Community Expert Group]
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
Extensions available
8 REPLIES 8

Re: Converting a recorded script to Connect C#

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

Contributor

Re: Converting a recorded script to Connect C#

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

Community Hero

Re: Converting a recorded script to Connect C#

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
[Community Expert Group]
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
Extensions available
Contributor

Re: Converting a recorded script to Connect C#

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.

Community Hero

Re: Converting a recorded script to Connect C#

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
[Community Expert Group]
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
Extensions available
Contributor

Re: Converting a recorded script to Connect C#

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

Community Hero

Re: Converting a recorded script to Connect C#

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
[Community Expert Group]
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
Extensions available
Community Hero

Re: Converting a recorded script to Connect C#

running automation from visual studio help.png


Robert Martin
[Community Expert Group]
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
Extensions available
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors