GherkinUFT  Scheduling Tasks


 

With the GherkinUFT Runner.vbs script, you can drop any .Feature or .xsl file into any one of your Queue folders and UFT will start to run your script. 

Just set up a Scheduled Task to run every minute to check if there are any scripts to run. 

    

       Schedule .mtb Batches

When you put your Feature Pack .mtb files together, you can choose the date & time to run the pack. You can also choose the PC to run on, and which preceding feature must have already run.

Schedule by Date: RunScheduleStartDate=2020\01\10

Schedule by Time: RunScheduleStartTime=08:30

Schedule on PC: RunIncludePC=GBWP1234, RunExcludePC=GBWP5678

Schedule wait for previous Feature: RunDependancy=IBMT_NEWA007a_Second_Property_Security

    

Scheduled Task runs vbscript

C:\Windows\System32\cscript.exe "\\server\UFT_Gherkin_Automation\BatchControls\UFTqueRunnerv2001.vbs"

    

    UFTqueRunner.vbs Runs

Reads in the Runtime_Environment.xml config file parameters, and if its an .mtb batch file it reads in any override parameters if found. These runtime parameters are then written out to text files so that the UFT framework initialise Function library can read them in. 

Recently I got an opportunity to give Training on DevOps. One of the special requests was to solve the integration UFT One with Azure DevOps to run their Automation Tests. Going through the marketplace and solutions over the Internet, I didn't find anything helpful. There were some UFT extensions in Azure Marketplace but they were majorly on integration with Self Hosted Azure DevOps Services and not with Azure DevOps SaaS Solutions.

What do you think engineers or developers do when there are no available integration or solutions? They make their own way. So with this motivation and a target in mind, i.e., to showcase the integration in my Presentation, I started thinking about the ways to do it.

There is one DevOps formula I follow:

If you can run something using PowerShell/CMD in your local computer, you can do the same from any DevOps Tools.

So I started brainstorming the ways the UFT can execute the Automated test scripts through a Powershell command by opening itself, running, generating a report, and then closing by itself.

There were VBScript commands which are used by UFT to execute its application. To automate this we needed to execute the VBScript attached to a windows batch process. Then, we need to run this in the server where our UFT is hosted and Azure DevOps needed to trigger this batch jobs in that Server.

So here are the Step by Step process, I followed to Automate it..

Prerequisite:

1) A Virtual Machine with a UFT One Testing Automation Software Installed.

2) An Azure DevOps account

3) Test Scripts for Testing

Step 1: Creating of a Self-Hosted Agent

1) Go to Azure DevOps and create a Personal Access Token. Save the Token at Safe Place.

2) Go to your Project Settings and to Agent pool section-> Default pool.

3) Click on New Agent and download the agent.

4) Copy the Agent to UFT One VM, and keep it under download folder

5) Follow the steps to configure your VM as a Self Hosted Agent

In Azure DevOps Agent pool you will see the Agent will Show Online

Step 2: Create a BAT file and VB Script file for UFt Automation inside your UFT Test Solution.

1) In VS Code inside UFT Test Root folder create a "mytest.bat" file and copy and paste the following script. (You can use any name for the file)

cd c:\windows\syswow64

cscript.exe "myvbs.vbs"

exit

2) In the same root folder, create myvbs.vbs file and paste the following scripts. ( in Test-Path -> Put the Folder name of your Test which is in root Directory under the same tree as this file)

testPath = "<Path of your test Scripts>"

Dim objFSO

Set objFSO = CreateObject("Scripting.FileSystemObject")

DoesFolderExist = objFSO.FolderExists(testPath)

Set objFSO = Nothing

If DoesFolderExist Then

Dim qtApp

Dim qtTest

Dim qtResultsOpt

Set qtApp = CreateObject("QuickTest.Application")

qtApp.Launch

qtApp.Visible = True

qtApp.Open testPath, False

Set qtTest = qtApp.Test

Set qtResultsOpt = CreateObject("QuickTest.RunResultsOptions")

qtResultsOpt.ResultsLocation = "<Path to upload Report>"

qtTest.Run qtResultsOpt,True

qtTest.Run

qtTest.Close

qtApp.Quit

Else

End If

For the qtResultsOpt.ResultsLocation , Create that folder inside the VM agent and copy that path for this variable. This is where your Test Report will be stored.

3) Your tree Structure should look like this:-

4) Checkin and push your code to a repository in Azure Repo

Step 3: Create a Stage/Pipeline for executing the test scripts.

1) Go to the Pipeline of application for which you want to run this test.

2) Add the UFT Test artefact, by selecting Azure Repo-> UFT Test Repo -> master branch -> latest . Save the artefact

3) Add a Stage after the dev stage named Smoke(or any test), you want to run in your UFT Machine

4) Click on Smoke test stage on Job link in blue

5) Select the Agent Job, and Choose Agent Pool as "default", to make your UFT Virtual machine as an agent machine to run this test.

6) Now click on + and add a command-line task

7) In CMD Task, you have to execute the VB Script which you have pushed in your repository which will be there in agent machine after deploy.

8) Add the path

$(Pipeline.Workspace)\<Your Test Artefact Name>\myvbs.vbs

In my case the Artifact name is _AutomationTest, So my script command will be

$(Pipeline.Workspace)\_AutomationTest\myvbs.vbs

9) Run the Pipeline and watch the VM, you will see the UFT test will run successfully.

10) Browse to your ReportsFolder location, which you put to have the report and check the Html file for the Report.

There will be a report.xml file generated. You can convert it to a JUnit file and create a task to publish the test results in the Smoke Test Stage which will upload the Report to Azure DevOps.

Alternatively, You can decide how you want to show this report. This folder can be pushed to a public location to be accessible by any team for the test reports, or you can make it as a website to show the report or you can decide to create a mail task to send this report via mail to target users.

For Demo, I have hosted the Report folder over IIS and all report is visible on a reports Portal Url as shown in Image below.

Hope the information was informative and would help you in automating your UFT/QTP test in Azure DevOps Pipeline.

<<<<< Back to Dashboard Monitor                                                                                 Forward to QC / ALM >>>>>