How to Execute UFT Test Silently

silent_test_runner

HP provides less known utility along with UFT that also allows user to execute UFT Tests Silently (without opening UFT GUI). Actually, there are 2 ways to achieve this:

  1. Using Silent Test Runner: This utility is located at <UFT Installation Directory>\bin\ SilentTestRunner.exe To execute the Test silently, just launch the utility, select the Test that needs to be executed and click on Run Test button.Silent Test Runner provides test run information in log files. Each test generates a test run log, and  any test with transactions generates an additional transaction summary. The test run log is saved as output.txt in the <Unified Functional Testing>\Tests\<test name> folder. The transaction summary is saved as transactions.txt in the <Unified Functional Testing>\Tests\<test name> folder. A log/transactions summary file is saved for each test run with Silent Test Runner and is overwritten when you rerun the test.silent_test_runner
    2.Using mdrv.exe:  To execute the test from command line, user just needs to invoke the following command from command prompt. As shown in the following snapshot, we need to provide full path of usr file of the Test that user needs toexecute as a parameter to mdrv.exe
    This usr file is present inside every UFT Test and is created automatically.

cmd
         Few points that needs to be considered while executing Tests silently:

  • Only one Test can be executed silently at a time
  • There should not be any error in the Test as Test exits on encountering an error without giving any message
  • There should not be any msgbox statement in the executed Test
Tagged with: , , , , ,
Posted in Awesum Stuff

Types of Webservices (REST)

In the last post, we learnt about the intricacies of SOAP Webservices. In this post, we will learn and explore REST Webservices in detail.

REST stands for Representational State Transfer. It is a lightweight alternative to SOAP,RPC etc for data transfer. It uses HTTP as communication medium and  mostly JSON as message format. It is preferred to be consumed in mobile applications as it is lightweight in comparison to SOAP, however, it has no inbuilt security mechanisms. SOAP can be thought of as letter in an envelope whereas REST is postcard in this analogy. Before knowing more about REST, we need to understand HTTP messages.

HTTP Messages are made of a header and a body. The body can often remain empty; it contains data that you want to transmit over the network, in order to use it according to the instructions in the header. The header contains metadata, such as encoding information; but, in the case of a request, it also contains the important HTTP methods.

REST is basically a set of design principles consisting of resources and methods to access/manipulate those resources. Resources are best thought of as nouns. For example, the following is not RESTful because it uses a URL to describe an action.

/clients/add

HTTP Verbs are specified along with the request. Methods are then mapped to HTTP verbs/methods. Mostly, 4 HTTP verbs/methods are used (GET/PUT/POST/DELETE)

a) GET – It is used to request the resource
b) PUT – It is used to update the resource
c) DELETE – It is used to delete the resource
d) POST – It is used to create the resource.

Here, it is very important to know about Idempotent methods. These methods achieve the same result, no matter how many times the request is repeated. In the above 4 methods, GET, PUT and DELETE are idempotent methods whereas POST is non-idempotent method.

HTTP Responses contains response codes in its header that is basically a way of informing client about the results of its request. Following are some of the response codes:

a) 200 OK –  It indicates that the request was successful.
b) 201 Created – It indicates the request was successful and a resource was created.
c) 400 Bad Request – The request was malformed.
d) 404 Not Found – Required resource could not be found.
e) 401 Unauthorized  – Authentication needed / not successful.
f) 405 Method Not Allowed – HTTP method not supported for this resource.
g) 409 Conflict – This indicates a conflict. For instance, POST request is used to create the same resource twice.
h) 500 Internal Server Error – When all else fails; generally, a 500 response is used when processing fails due to unanticipated circumstances on the server side, which causes the server to error out.

In the next article, I will introduce you to new version of UFT (which has API Testing Capability)

Tagged with: , , , , , , , , , , , , ,
Posted in Awesum Stuff

Types of Webservices (SOAP)

SOAP

In the last post, we learnt about the differences between API and Webservices. In this post, we will learn about the types of Webservices with SOAP Webservices in detail.

A Webservice needs the following entities to perform its operations:

1) Communication Medium
2) Messages Format

Webservices are basically of 2 types:

1) SOAP
2) REST

SOAP is an earlier form of webservice whereas REST is relatively new form of webservice introduced in favor of simplicity and speed.

1) SOAP stands for Simple Object Access Protocol. It was originally developed by Microsoft to replace older technologies that don’t work well on Internet such as DCOM and CORBA. It uses HTTP as communication medium (other protocols can also be used such as SMTP) and SOAP as message format. SOAP format is nothing but a standardized XML defining which content should go inside which node (envelope,body etc). One of the most important SOAP features is built-in error handling. If there’s a problem with the request, the response contains error information that can be used to fix the problem. This particular feature is extremely important in cases where user doesn’t generally own the service; otherwise debugging would be nightmare.

As told in the previous post, an application providing access to a service is called a service provider and the application using the service is called service consumer. To connect to a SOAP Webservice, some information is required (such as functions exposed by the service, port number on which service is accessible etc). Service Provider captures the required information in a XML file called WSDL (Web Service Description Language). There are 2 ways by which consumer can get the WSDL file to connect to particular Webservice provider.
a) Either consumer can get the WSDL file/URL directly from the provider
b) Consumer can get the WSDL file/URL from UDDI (Universal Directory for WSDL)

For second point, it is necessary for service provider to register the Webservice in UDDI using WSDL. UDDI (Universal Description, Discovery, and Integration) is an XML-based registry for businesses worldwide to list themselves on the Internet.

Below is the diagrammatic description of SOAP Webservices:

SOAP

In the next post, we will learn about another type of Webservice (REST).

Tagged with: , , , , , , , , , , , , , , , ,
Posted in Awesum Stuff

Webservice vs API

To understand Web services clearly, one has to understand what an API is. API stands for Application Programming Interface. It is basically a set of functions exposed by an application/module to be used by another application/module. Under this terminology, the application using the exposed function is called Consumer and application that is exposing the functions is called Provider.

Although you can assume that a Web service is a subset of the generic term API,here are some of the subtle differences between API and Web services:

1) In API, both consumer and provider software reside inside same machine whereas in Web service, both software are in the different machines.
2) Network is not needed in case of API whereas both the machines should be connected to same network in case of Web service.
3) Web services are language independent whereas API can be language independent
4) Web services might not perform all the operations that an API would perform.They are mostly used when we want to request some data from the server.

From above points, we can infer that All Web services are APIs but all APIs are not Web services or we can also say that a Web service is simply an API wrapped in HTTP.

 

 

Tagged with: , ,
Posted in Awesum Stuff

How to Add LeanFT Dependency in Maven

Maven is an important component of a Test Automation Framework. If you want to add LeanFT dependencies in Maven, you need to perform the following steps:-

  1. Install Maven on your system. Mkyong explains it beautifully in his post here.
  2. Execute the following 2 commands on your command prompt to add the LeanFT Jars in your local maven repository:-

mvn install:install-file -Dfile="C:\Program Files (x86)\HP\LeanFT\SDK\Java\leanft-jars\com.hp.lft.report.jar" -DgroupId="com.hp.lft" -DartifactId="com.hp.lft.report" -Dversion=12.53.0 -Dpackaging=JAR -DgeneratePom=true

mvn install:install-file -Dfile="C:\Program Files (x86)\HP\LeanFT\SDK\Java\leanft-jars\com.hp.lft.sdk-standalone.jar" -DgroupId="com.hp.lft" -DartifactId="com.hp.lft.sdk" -Dversion=12.53.0 -Dpackaging=JAR -DgeneratePom=true

3. Add the Following dependencies in your pom.XML:-


 <dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>com.hp.lft.sdk</artifactId>
    <version>12.53.0</version>
 </dependency>

 <dependency>
    <groupId>com.hp.lft</groupId>
    <artifactId>com.hp.lft.report</artifactId>
    <version>12.53.0</version>
 </dependency>

Please note that the version specified in the Command line arguments and the pom.XML would change depending on the version of LeanFT installed on your machine.

Happy Automating !

Harshit Kohli

Tagged with: , , ,
Posted in LeanFT

LeanFT Service Pack 3 – Whats New ?

LeanFT just got more AWESOME ! HP recently launched Service Pack 3 and here are some of the cool features:

  • Parallel execution on the same machine: Speed up your testing by running in parallel multiple tests on the same host on your Web applications. Reduce your Total Cost of Ownership because with one LeanFT license you can execute up to four tests at a time.
  • IntelliJ IDEA is now supported with LeanFT for creating LeanFT’s test projects and enjoying all the advantages of our solution like application models and the identification center.

                                                                                 432.JPG

  • TestNG, NUnit3, Maven-based Java projects are now supported, expanding our support of unit-test frameworks
  • JavaScript SDK main enhancements: OCR, More tech: Insight, SAPUI5, Access to the NativeObject, Checkpoints
  • Creating Business Components for BPT
  • Mobile testing enhancements: Using LeanFT and Mobile Center 2.00, you can now:
    1. Support non-packaged apps. This means you no longer need to package apps and to upload them to Mobile Center.
    2. Dynamically select and lock a device for your test by specifying the device’s operating system type and version.
    3. Access mobile device logs from the LeanFT run report.
  • Business Process Testing (BPT) is now supported as you can transform any LeanFT test to become a LeanFT business component, bringing together the best of both worlds—rapid test automation leveraging developer environments and the ease of creation and maintenance that comes from adopting a component test framework .

For downloading the Latest version, you need an HP License. In case you have one, you can download from this link.

If you want to Learn LeanFT, you can start from here.

 

Happy Automating!

Harshit Kohli

Tagged with: , , ,
Posted in LeanFT

LeanFT Java Tutorial Part 9 – Using LeanFT and Selenium Together !

I don’t want to debate which tool is better, of course both tools have their advantages and disadvantages. So lets use all the advantages together in a mega script which uses both technologies. For doing this, you have to:-

  1. Create a LeanFT JUnit Project in Eclipse.
  2. Download Selenium Libraries from here and extract to a desired location.
  3. In your Eclipse project, right click the Project name and goto Build Path -> Configure Build Path.
  4. Click on Add External Jars option and add the selenium-java-{version}.jar from the extracted location.
  5. Also add all the jars in the libs folder.
  6. If you are working with Chrome, you need to additionally download the chromedriver.exe from here.
  7. Now the setup is done, you can get your hands dirty with the following code:-

package l2a;
import static org.junit.Assert.*;
import java.io.File;
import org.junit.*;
import com.hp.lft.sdk.*;
import com.hp.lft.sdk.web.*;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.*;
import unittesting.*;

public class LeanFtTest extends UnitTestClassBase {

 public LeanFtTest() {
 //Change this constructor to private if you supply your own public constructor
 }

 @BeforeClass
 public static void setUpBeforeClass() throws Exception {
 instance = new LeanFtTest();
 globalSetup(LeanFtTest.class);
 }

 @AfterClass
 public static void tearDownAfterClass() throws Exception {
 globalTearDown();
 }

 @Before
 public void setUp() throws Exception {
 }

 @After
 public void tearDown() throws Exception {
 }
 
 @Test
 public void leanFTSelenium()
 {
 try
 {
 //Setting the Path for Chrome Driver
 System.setProperty("webdriver.chrome.driver", "C:\\Selenium\\chromedriver.exe");
 
 //Adding the Chrome Extension for LeanFT
 ChromeOptions CO = new ChromeOptions();
 CO.addExtensions(new File("C:\\Program Files (x86)\\HP\\LeanFT\\Installations\\Chrome\\Agent.crx"));
 
 //Launching Chrome with Selenium 
 WebDriver driver = new ChromeDriver(CO);
 
 //Navigating to Google
 driver.navigate().to("https://www.google.com");
 
 //Attaching to the Browser with LeanFT
 Browser browser = BrowserFactory.attach(new BrowserDescription.Builder()
 .type(BrowserType.CHROME).build());
 
 //Navigating to Learn2Automate on the same browser instance
 browser.navigate("https://learn2automate.wordpress.com");
 
 }
 catch(Exception ex)
 {
 ex.printStackTrace();
 Assert.fail("Unexpected Error occurred - " + ex.getMessage());
 }
 }

 

After writing the above code, your “browser” and “chromeDriver” objects are pointing to the same browser instance. You can now use both objects interchangeably in your script, this essentially means you can write either Selenium or LeanFT code for performing an action on your browser. Talk about Flexibility !

For more information on using Selenium in Java, you can refer many blogs that write about it.

Happy Automating!
Harshit Kohli

Tagged with: , , , ,
Posted in LeanFT
Blog Stats
  • 117,219 hits
Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 724 other followers

%d bloggers like this: