Create a UFT Developer | LeanFT Testing Project & Write First Test

Micro Focus has rebranded LeanFT as UFT Developer. In this article, I will explain how to create a LeanFT testing project or UFT Developer testing project and create your first Test. If you want to know how to download and install UFT Developer and configure it in Eclipse IDE please refer to my post on UFT Developer Installation in Eclipse IDE. If you want to get an overview of UFT Developer please click here.

Note: The screenshots in this article are of LeanFT. However, the steps of creating a project in LeanFT and UFT Developer are the same.Please select the relevent options while creating the project if you are using UFT Developer.

Steps to Create a UFT Developer Testing Project And Create a new Test

Step1: In the Eclipse IDE go to “New>File>Project“.Select LeanFT Testing Project and click on the Next Button.

Create a LeanFT Testing Project

Step 2: In this step, we will have to select the testing framework that is either JUnit or TestNG.Since TestNG is the most renowned framework and widely used across the organizations, let’s select TestNG.If TestNG is not configured in your eclipse please refer to my post on How To Install TestNG in Eclipse.

Testing-Framework-TestNG-LeanFT

Step 3: Now you will have to enter the name of the project and package name. You can use the same what is given in the below screenshot and click on the Finish button. If you see a New module-info.java dialog box click on the Don’t Create button.

 LeanFT-New-Project2

Step 4: You will see that LeanFT automatically creates LeanFtTest.java file inside the “com.test.MyLeanFT” package with the following empty template.

TestNG-Error-LeanFT

Step5: You will see there are errors in the project because the TestNG library is missing. If TestNG is already installed in Eclipse we can add the TestNG library to our project. To add the TestNG library place your mouse over the red underlined text. The eclipse will automatically show the suggestion to add the TestNG library. Click on the Add TestNG library option.

 add-testng-library-LeanFT

Step6: You will see that all errors have been fixed and the TestNG library has been added to the LeanFT project

 Fixing-TestNG-Error-LeanFT

Step7: You will notice that there are few empty methods with different TestNG annotations starting with @symbol.
 
The followings are the meaning of each annotation. I will discuss more TestNG annotations and how to use them in some other article.
  • @BeforeClass: The annotated method will be run before the first test method in the current class is invoked. 
  • @AfterClass: The annotated method will be run after all the test methods in the current class have been run. 
  • @BeforeMethod: The annotated method will be run before each test method. 
  • @AfterMethod: The annotated method will be run after each test method.
  • @Test: This annotated method is the actual main test method where you will have to write your actual test logic 

Step 8: As of now we will only use @Test annotation and delete the rest of the methods with other annotations. Now copy the following code in the LeanFtTest.java file.

Now run this code as a TestNG test. Do a right-click anywhere in the code and select “Run As>TestNG Test

Run As TestNG Test

Code Explanation

Let’s try to understand how the above code works. If you are working with web applications make sure you are importing web packages import com.hp.lft.sdk.web.*. Inside the LeanFtTest class, we have declared an object for the browser and the actual code of the test script has been written inside the test method. The @Test annotation of TestNG indicates that it is the main test method.
 
Inside the test method, we are using try and catch statements to handle any unwanted exceptions during the execution. We are navigating to www.google.com using the navigate method that is accessible through the browser object.
 
Next, we are creating a description object for each test object(like EditFieldButtonLink, etc) in the web application on which we want to perform an action. You have to use the Object identification Center (OIC) to create a description of the objects. If you do not know about OIC please refer to my post on How to Use Object Identification Center in LeanFT (UFT Developer).
 

Recommended Posts

Leave a Reply