blogs

Introduction To API’s & How To Automate API’s Testing With Selenium Webdriver?

Introduction To API’s & How To Automate API’s Testing With Selenium Webdriver? 06 Feb,2017

An application-programming interface(API) consists of a set of standards and programming instructions for accessing a Web tool or Web-based software application. Application Program interface is a set of protocols, routines and tools required for building software applications. An API specifies the way in which the software components should interact. Additionally, APIs are used when the graphical user interface(GUI) components are to be programmed. A good API provides all the building blocks and makes it easier to develop a program. A programmer puts all the building blocks together.

Different types of APIs are available for operating systems, applications or websites. For example, ‘Windows’ has many API sets that are being used by the system hardware and applications i.e. when users copy and paste text from one application to another, it is the API that makes it work. Most of the operating environments, such as MS-Windows also provides APIs which allows the programmers to write applications that are consistent with the operating environment. Today, the websites also specify the APIs. For example, with the help of Amazon or eBay APIs, developers can create specialized web stores by using the existing retail infrastructure. Third-party software developers can also use the Web APIs so as to create software solutions for the end-users.

An API is not a user interface but a software-to-software interface. With APIs, applications are allowed to communicate with each other without any user intervention. When you buy movie tickets online and enter your credit card information, Web site makes use of an API to send your credit card information to a remote application that verifies whether your information is correct or not. Once the payment gets confirmed, the remote application sends back a response to the Web site notifying that it is ‘OK’ to issue the tickets.

Introduction to Selenium WebDriver:

 

53670_9ee2_711

WebDriver is one of the most powerful and popular tools of Selenium toolkit. WebDriver is an extended version to Selenium RC with surplus advantages and it overcomes many of its limitations. Unlike Selenium IDE, WebDriver provides support to many latest browsers and platforms. In case of WebDriver, selenium server isn’t required to be started prior to the test scripts execution unlike Selenium RC. Selenium 2.0 is an aggregation of Selenium RC with WebDriver API. Selenium was developed so as to support dynamic web pages and Ajax calls. It also supports various drivers to perform web based mobile testing.

Selenium WebDriver Framework for API Testing

IT enterprises globally are implementing various automation solutions in order to provide effective and efficient software testing services. New and innovative approaches have been developed for test automation utilizing Selenium framework, thereby helping the enterprises to improve their service quality and thereby reducing the costs. Keeping this in mind, Selenium framework has been developed as it helps the testing teams to automate the validations of URL based APIs.

Selenium Based Automation Regression Suite:

Selenium framework is a data driven solution which consists of i) Java based Driver scripts ii) Frameworks methods created as per method types of APIs.

Benefits of Selenium Framework

 

1. Selenium framework takes considerably less time to prepare test data or to validate each scenario in comparison to manual testing.

2. For the preparation of the data and to validate 350 scenarios, it takes approximately 7 man days per resource. However, with the implementation of the selenium framework the time gets reduced to 1.5 hours (approximately).

3. It is easy to develop the Selenium framework and the test cases can be maintained effortlessly.

4. It is possible to integrate the Selenium framework with Continuous Integration(CI) build deployment process.

Example:

 

public static String PostRequest(String PostRequestURL,String Parameters) throws

Throwable {

String responseData=””;

System.setProperty(“http.proxyHost”, “Proxy server IP”);  // Enter your proxy name here

System.setProperty(“http.proxyPort”, “Proxy server port”);

HttpPost POSTrequest = new HttpPost(PostRequestURL);

StringEntity param =new StringEntity(Parameters);

POSTrequest.addHeader(“content-type”,”application/json”);

POSTrequest.setEntity(param);

HttpResponse response = httpClient.execute(POSTrequest);

BufferedReader  rd = new BufferedReader(newInputStreamReader(response.getEntity().getContent()));

int statuscode=response.getStatusLine().getStatusCode();

Assert.assertTrue(statuscode==200, “Failed : HTTP error code :”+statuscode);

responseData=rd.readLine();

System.out.println(“output is =” +responseData);

return responseData;

}

Selenium framework simplifies API validation by building the test cases.  The same can be leveraged for a selenium driven automation engine to validate and update the test execution results.

HarmanJeet Kaur Harman is an Automation Test Engineer at BugRaptors. She has expertise in Web & Mobile automation testing using Selenium WebDriver and Appium Tool. Professional in writing automating test scripts ,Data Driven Implementation , Keyword frameworks, Debugging, Executing and find issues in scripts.

Your comment has been posted successfully!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Name field is required !

12345 Rating field is required !

Related Posts

Introduction to Automated Testing Life-cycle Methodology
Introduction To API’s & How To Automate API’s Testing With Selenium Webdriver?

Automated Testing Life-cycle Methodology is the process of testing which is executed in planned and a systematic manner. In this process, different ac...

Read More
Challenges and Opportunities Faced While Migrating To Seleni...
Introduction To API’s & How To Automate API’s Testing With Selenium Webdriver?

Organizations are getting digitally powered and are liable for ensuring digital empowerment for its customers. The Gartner's CIO Agenda (2016) Surve...

Read More
How To Run Parallel Execution In Selenium Grid Using TestNG?
Introduction To API’s & How To Automate API’s Testing With Selenium Webdriver?

Selenium Grid is a proxy server that enables the user to run tests in parallel on multiple machines. It manages different browser versions and config...

Read More
Introduction To Selenium 3.0: An Upgradation Using GeckoDriv...
Introduction To API’s & How To Automate API’s Testing With Selenium Webdriver?

Selenium 2.0 was released in 2011 and introduced the new WebDriver APIs that encouraged everyone to start moving to them. Selenium 3.0 is a simple dro...

Read More

Popular Blogs

What Is ETL Testing & How To Enforce It In Data Warehouse?
What Is ETL Testing & How To Enforce It In Data Warehouse? Read More
How to test your Android App: Key Techniques to get you started
How to test your Android App: Key Techniques to get you started Read More
Boost your business using Test Automation
Boost your business using Test Automation Read More
3 Reasons Why to Invest Time and Money in Regression Testing!!
3 Reasons Why to Invest Time and Money in Regression Testing!! Read More
Measure Performance of the Application – Using Open Source Performance Testing Tools
Measure Performance of the Application – Using Open Source Performance Testing Tools Read More

Sign up FOR NEWSLETTER !

Do you want to automate your web application?
contact us