UFT GIT Integration

In this post we will discuss about how to integrate UFT with a GIT Repository. We will use UFT 14 with GIT hub repository for this post.

To use GitHub, you can create a new account at github.com.

Assumptions: GIT is already installed on your system. You can grab the installable files below

https://git-scm.com/downloads

Creating a GitHub Project

Login to your GitHub account and create new repository

Enter a Repository name and provide description.

If you want a private repository, then you will have to pay for it, for this demo I will use public repository with No License

Click on create Repository.

Once the repository is created then you will have to initialize this repository in one of the folders on your computer.

This folder will serve two purposes

  1. This will be the connection point between your Git repository on GitHub.Com and your UFT Test.
  2. You will open your UFT test from this folder and make changes here.

Initialize Git Repository on your System

  1. Create a folder on your computer.
  2. Copy the Clone path from your Git Hub repository

https://github.com/XXXXXXXXX/Repository_Name.git

  1. Open GIT GUI

  2. Click on Clone Existing Repository

  1. Source Location is the GitHub Repository location you copied before and target is the folder you created on the local computer.

  1. Click Clone. Git GUI will clone the repository. Close the GIT GUI Tool.

Note: You can also clone the git repository using the following two commands inside git bash or inside command prompt (If Environment variables are set).

You must navigate to the directory where you want to clone the project

git init

git clone https://github.com/<Git Clone path>.git

Creating UFT Test

Once your Git repository is created and Remote is added, you are now ready to create your UFT test.

Open UFT and Click on New->Test

In the new test window, Provide the name of the test and select the folder, where you have initialized the GIT repository.

Click on create button.

Open Solution explorer and you should see small red circular icon below Test and Action names. This indicates that the files are not pushed to the GitHub project yet and they are only available in your local folder.

Pushing Changes to the GitHub.com Repository

To push the changes to the online repository

  1. Right Click on the Test case name and Select ‘Git Commit’.

  2. Enter the Commit message, and click on OK button.

  3. You should see ‘Commit Succeeded’ on the bottom left corner of UFT

  4. Open the solution explorer again and you should see green check marks on test and action.

  5. Right click on the test again and select ‘GIT Push’.

  6. Click OK. This will push the changes to GitHub.Com repository.

  7. Enter User name and password for GitHub.com, and Click on OK button.

  8. UFT will push the changes to GITHub repository.

  9. You will see the message ‘Push succeeded’ on the bottom left corner of UFT

Now you have successfully uploaded the changes from UFT to GitHub Repository. Open the Repository and you should see the UFT test files there

This completes the basic tutorial. Now let’s get into some of the advanced stuff.

Creating and Merging Branches

By Default, Git creates a Master Branch and this branch must always have your latest copy of the runnable code (Generally).

If you have to change the test you have previously created, you should always create a separate branch for the changes and once the changes are done then you should merge those changes back to the Master branch.

Consider the below scenario,

If you have created a test for login to Gmail. Now if google changes the image on the login page and you want to update the image checkpoint there, then

  1. You should create a separate branch (e.g. Google_Login_Image_Chkpnt_Update) in your Git repository and check it out. This will create a copy of your existing code.
  2. Update the code changes and test them in a local computer.
  3. Once you are satisfied with the code changes then, Merge this Branch(Google_Login_Image_Chkpnt_Update) from local computer with the Master Branch on GitHub repository. This will update the Master Branch with the latest code.

How to create a branch?

UFT does not provide us the tools to create the branch.

To create a new branch

  1. Right click and open the Git bash.

  2. On Git bash execute the following command

Git checkout –b <New_Branch_Name>

This command will create a new local branch and check it out in your local repository.

  1. Now close UFT test and open it again (Just to make sure that changes are in effect).
  2. Update your test and save it.

  3. Now go to your solution explorer and you will see small red circles on the test and action name. This means that the changes are only available in your local repository.

  4. Commit and push the changes (As discussed before).

  5. Your will see that there are two branches in your GitHub.com Repository.

  6. Click and open the Branch “Google_Login_Image_Chkpnt_Update”. You will see the commit message we have provided.

Reverting Back the changes you made

Now your changes for the Google Image checkpoint is inside the “Google_Login_Image_Chkpnt_Update”. After your first commit, you can revert the changes back to this commit using Git Revert command in UFT.

So to demonstrate this I will add another message box in Action 1 and save the test.

Now open the solution explorer and Right click on the test name and Select “Git Revert”.

UFT will close the test and reopen it. All of your changes since the last commit and push will be deleted.

Code in Action 1 is reverted back to

Comparing UFT Test with Previous versions

if you have made changes in the local repository, then you can compare the local repository test to the last commit using Compare with previous revision option.

Now I am adding the same message box again and then I will compare this to the code available on github.com

To Compare the code with previous version

  1. Right Click and Select -> Compare with previous version.

  2. Asset comparison tool will open.

  3. A blue down Arrow in front of the assets represents that we can drill down and see the actual differences. So in this case I am clicking on the blue down arrow in front of Steps
  4. Comparison window for steps will open

  5. You can also see the changes in the test settings for the two versions Under Test Settings.

Commit and push the changes. We will merge this change to master repository

Merging Changes to the Master Repository on Git server

UFT does not provide any tool for Merging the changes back to Master Repository, so we will do it with bash commands.

We will merge the changes from “Google_Login_Image_Chkpnt_Update” local repository to master repository on the git server.

Open the bash and type the following commands

git checkout master

This will checkout the master branch. After this execute

git merge Google_Login_Image_Chkpnt_Update

This will take the changes from Google_Login_Image_Chkpnt_Update repository and update it in master repository.

Close and open UFT test, your Master branch will now have the changes from the Google_Login_Image_Chkpoint_Update branch.

The main learning point is that UFT Git integration is still not as good as eclipse – Git integration, and UFT still can’t deal with Git branches very well. Hopefully in future release we will have a lot of other functionalities included.

For your reference, you can get more details about Git commands below

https://git-scm.com/book/en/v2/

Or you can download the Git book below

https://progit2.s3.amazonaws.com/en/2016-03-22-f3531/progit-en.1084.pdf

Let me know, if you have any questions in comments.

Advertisements

9 responses to “UFT GIT Integration

  1. Pingback: UFT GIT Integration | Automation Insights·

  2. Pingback: UFT GIT Jenkins Integration | Automation Insights·

    • Hi Lisa,

      You can do UFT executions from any where, you only need two things

      1) Download UFT scripts to a folder
      2) Run the script using UFT’s AOM.

      I have no experience with Gitlab-ci.yml, but I am sure you can do it, if it allows you to run custom scripts.

      Let me know if you need any other help.

      Like

  3. Hi Sumit,
    So for UFT , GIT to be integrated , we need to have both on same machine ?
    I have UFT on remote desktops and GIT on local network.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s