Pages

Friday, April 24, 2015

Execute the TestComplete TestExecute module remotely on a VM using PSExec

Using the SysInternals tool PSExec.exe to launch TestExecute and run a project on a VM.

  1. Login to VM as normal user
  2. Run PSExec from command line (or batch file) on local machine.  I was having trouble with this; needs to be username not in quotes and password in double quotes.
C:\SysInternals\PSTools\PsExec.exe \\TESTVM -u domain\user -p "P@$$w0rd" -i \\TESTVM\C$\Users\testaccount\Downloads\TestExecuteRemote.bat
  1. User launching PSExec.exe is the same user logged in to the VM (without admin rights)
  2. -i option executes interactive
  3. TestExecuteRemote.bat contains command line to call TestExecute that looks like this:
:: Run TestExecute and export log to c:\LOG\ExportLog.mht
:: Log file cannot exist or test will fail to run
:: Test account needs write permission to the project folder (log is also generated under project)
"\\TESTVM\C$\Program Files (x86)\SmartBear\TestExecute 10\Bin\TestExecute.exe" \\TESTVM\C$\Test\ProjectSuite1\ProjectSuite1.pjs /r /e /DoNotShowLog /ExportLog:\\TESTVM\C$\LOG\ExportLog.mht

PSExec.exe has an option for -l to run as limited user, but the remote batch file failed to run using that option. 

Sunday, January 4, 2015

STEP #6: Add Custom Assertion to UIMap1.cs file that verifies properties of an HtmlHyperlink add call to assertion method and code to log messages using TestContext.WriteLine to CodedUITestAmazon.cs

Expand UIMap1.uitest in solution explorer to see the two files: UIMap1.cs is where we add the custom code and UIMap1.Designer.cs contains generated code which is just the definitions of the controls on the page in this case

Double Click UIMap1.cs and UIMap1.Designer.cs to open both files and copy using directives from UIMap1.Designer.cs to UIMap1.cs


Add custom Assertion Method to UIMap1.cs that validates properties of an HTML Hyperlink

Add call to Assertion Method to CodedUITestAmazon.cs and log messages using TestContext.writeline in a new [TestMethod]

Select Build>Build Solution

Open Test Explorer under Test>Windows>Test Explorer

Select Test Method name, right click, and “Run Selected test”

Test Runs: Loads IE to www.amazon.com validates properties of hyperlink and logs messages to Output: result is displayed in TestExplorer

Click Output link to view messages that were logged

STEP #5; Add code to TestInitialize section of the CodedUITestAmazon.cs file that loads IE, browse to URL, and log message

Click + sign to expand region named “Additional Test Attributes” where the TestInitialize section is located in CodedUITestAmazon.cs file

Select [TestInitialize] code and uncomment using toolbar button

Add code to launch a new browser window and log a message using TestContext.WriteLine

STEP #4: Add the Using directive and Constructor to the CodedUITestAmazon.cs file

Open CodedUITestAmazon.cs file - double click in Solution Explorer
Add using directive to enable calls to custom methods and assertions that will be added to the UIMap1.cs file

Scroll to the end of the file to add the Constructor to make a new instance of UIMap1 named UIMap after “private TestContext testContextInstance”



Friday, January 2, 2015

STEP #3 Add Controls to UIMap1.uitest - this is a partial class so the generated code will be added to UIMap1.Designer.cs and we'll add custom code to UIMap1.cs

Load IE and browse to Amazon.com
Go back to Visual Studio, right click UIMap1.uitest and select “Edit with Coded UI Test Builder” and the builder loads in the lower right corner with Amazon.com open in IE

Left click and hold down the Cross Hair button, then drag to highlight the control to be added to the UI Map

Click the double arrow in top left corner and the UIMap is displayed

Click button in upper left corner to add the control to the map

The checkmarks turn dark gray but the UIMap has not been updated yet

Click the Generate code button to add controls to the map

You are prompted that there are no code changes except updates to the UIMap

Click Generate button and close the builder to return to Visual Studio
Double click UIMap1.Designer.cs and search for the control that was added - This tells you which properties the tool uses to identify the control on the page

UIMap1.Designer.cs contains the generated code that gets overwritten each time the solution is built





STEP #2: Rename the default CodedUITest1.cs file and dependencies

Right click CodedUITest1.cs file in Solution Explorer and rename to CodedUITestAmazon.cs
Hit Enter and you will be prompted with message: “You are renaming a file. Would you also like to perform a rename in this project to all references to the code element ‘CodedUITest1’?”

Click Yes and name is changed where the green indicators are displayed in the left column

You can also rename in the comments from CodedUITest1 to CodedUITestAmazon


STEP #1: Create New CodedUITest Project and manually add UIMap named UIMap1.uitest instead of UIMap.uitest Create CodedUI Test Project and add new UIMap1.uitest file

Run Visual Studio from Start menu and Select File> New> Project
Select Templates> Visual C#> Test> CodedUITest
Enter name for Project and same name is used for the Solution, make sure Add to source control is unchecked, and click OK

Click Cancel at message at prompt “How do you want to create your coded UI test”

Right click Project and select Add> New Item
Select Test under Visual C# items, select Coded UI Test Map, keep default name of UIMap1.uitest, and click Add

The CodedUI Test Builder loads - Click X in upper right corner to Close

Now you are back to Visual Studio with an empty UIMap1.uitest