Theme images by Storman. Powered by Blogger.

Software Testing

[best practices][feat1]

Recent

recentposts

Popular

Comments

recentcomments

Most Recent

Random Posts

randomposts

Facebook

page/http://facebook.com/letztest

Featured Posts

Friday, June 16, 2017

If you think you are too late to accomplish something in your life, just go through these.

- No comments
Recently I came-across a very interesting post in my LinkedIn feed and I couldn't stop myself to share that post in my blog as well.

I always had a thought in my mind,

Everyone have something to do in their life and if you find that something, then it will bring you everything.

This is something which I have phrased, so that I could always say this to me, mostly at the times when I am completely down. :)

Those born to become businessmen will do that at any age. These graphics by Anna Vital show us how important it is to always keep being yourself and work hard on your ideas, despite the stuff you're busy with now and the number of years estimating on figures in your passport.

Infographics of insppirational stories


How to start a startup

31 ways to be creative

how angry birds started

how airbnb started


how instagram started

how pinterest started

how to succeed in a startup






I am sure you are motivated enough! Now go and find that something which could bring everything in your life. :)

Feel free to drop your words below. :)

Tuesday, May 2, 2017

Learn API Test Automation using Postman in 15 minutes.

- No comments


Now-a-days we live in an exciting age of intelligence, where progress moves at the speed of imagination. We are connected to the entire world and to each another like never before. Have you imagined how we have made all these possible ?

API(Application Programming Interface) is the invisble hero here. Now let's try to know something about API’s and why/how API testing is gaining a vital role.

WHAT IS AN API?

API’s are used to connect or integrate two or more systems together ie. you can make data available for other systems to access via API or accept data from other systems. This is how different devices and applications talk to each other and share information.

Prominent companies like Google, Facebook, Twitter etc use API’s so that their application can communicate with third party programs. Do you know how a website works in a browser ? Usually API works similar to this way. A request is made from the client to the server and we get the response over the HTTP protocol. 

API Analogy

We can demonstrate API's using an interesting analogy. Letz consider a hotel where we can find mainly three components.

  1. a Customer
  2. a Waiter
  3. a Cook
API's are like waiters in a restaurant. The Waiter takes the request from the customers (which is the order for food)  and conveys it to the Cook (which is our server) and gets the food(response) from the cook to the customers. API’s do the exact same thing. API is the messenger that takes your request and tells the systems what to do and then returns the response back to you.

What is API Testing ?
 
API Testing is a type of software testing which involves testing the application programming interfaces (APIs) directly and as part of integration testing to determine if they meet expectations for functionality, performance, reliability and security. Since APIs normally lack a GUI, it's being performed at the business layer. During the API testing the data is exchanged from XML or JSON through HTTP requests and responses. Ideally these are technology independent and will work with any of the technologies and programming languages .

Postman is a Google Chrome app that helps you to create, save, send HTTP requests and test the response data.  It helps to automate the process of making API requests and testing API responses, allowing testers to establish a very efficient workflow. Most programmers and testers are familiar with Postman. However, many use it just to check the response for the services that they are working on. They are unaware of the powerful features that postman offers like: Collections, Tests and Pre-request scripts. In this article, I would like to give a quick overview of the test snippets provided by Postman.

Postman is very powerful with it's automation capabilities which makes it my favorite. Moreover, the learning curve for using it is very low and the app provides a very clean and intuitive user interface to test your server requests. These tests will validate every single time if the response is correct. JavaScript is the language used and it has also some inbuilt snippets, which allows any inexperienced tester to write an efficient test.

Frequently used snippets with practical examples:

Lets go through some of the frequently used snippets. To begin writing a test, first click on the ‘Tests’ tab under Postman ’Builder’ tab. You can select a snippet that is on the right panel.

This will generate a code template and you can modify it based on your context.
  • Snippet- ‘Status code is 200’
    tests[“Status code is 400”] = responseCode.code === 200;
This is the most basic snippet which checks if the response code is 200(The request has succeeded). You can use the snippet as is, with most positive scenarios. For scenarios as logging in with invalid credentials you can assign the response to 400(Bad request).

     tests[“Status code is 400”] = responseCode.code === 400;
  • Snippet- ‘Response time is less than 200ms’
tests[“Response time is less than 200ms”] = responseTime < 200;
This simple snippet checks if the response time was less than 200ms. You can modify it based on your context. For a scenario like uploading a large file you can edit this snippet as follows:

tests[“Response time is less than 1 minute”] = responseTime < 60000;
  • Snippet- ‘Response body: Contains string’
tests[“Body matches string”] = responseBody.has(“string_you_want_to_check“);
In case you are running a test that is attempting to log in with invalid credentials, assume that you will get a response like the one below. You can use this simple code to check for a string in the response.



 Response
 Test
 What the test does

{   “errorCode”: “TAR_ERR400_06”,
  “statusCode”: 400,
  “message”: “Invalid credentials.”
}



tests[“Body has the string invalid credentials”] =responseBody.has(“Invalid credentials. “);


This test snippet will check the response for the string “Invalid credentials.

  • Snippet- ‘Response body: JSON value check’
var jsonData = JSON.parse(responseBody); tests[“Your test name”] = jsonData.value === 100;
In case  you are trying to login with invalid credentials, the test below will check if the ‘errorCode’ in the response is correct.


 Response
 Test
 What the test does

{   “errorCode”: “TAR_ERR400_06”,
  “statusCode”: 400,
  “message”: “Invalid credentials.”
}


var data = JSON.parse(responseBody); tests[“errorcode “] = jsondata.errorCode === “TAR_ERR400_06”;


This test checks if the errorCode is: “TAR_ERR400_06”


Working with variables (Environment and global)

1. Environment Variables: Environments- give you the ability to customize requests using variables. This way you can easily switch between different servers without changing your requests.
  • To add an environment click on ‘No environment’ on the top right corner of the screen
  • Click on ‘Manage Environment’
  • Click on ‘Add’ and set the environment name as ‘Test’
  • You Can add variables as key value pairs
For example :  URL   https://productionserver.com

It is possible to create multiple environments and each could have a variable called ‘URL’-signifying the actual URL. For example, if we have 2 different environments called staging (url:https://stagingserver.com ) and production (url: https://productionserver.com), environment variables can be used in the form – {{variableName}}. The string {{variableName}} will be replaced with its corresponding value. Henceforth we can use the same request {{URL}}/userlogin and only switch the environment before running it.

After setting up the environments, you are just a click away from switching between environments.
  • Snippet- ‘Set an environment Variable’
    You can chain requests by extracting data from responses and assign them to an environment using test scripts. You can use the test snippet Set an environment Variable” to create an environment variable from your response data.
var jsonData = JSON.parse(responseBody); postman.setEnvironmentVariable(“variable_key”, “variable_value”);

 Response
 Test
 What the test does


{   “errorCode”: “TAR_ERR400_06”,
  “statusCode”: 400,
  “message”: “Invalid credentials.”
}



var jsonData = JSON.parse(responseBody); postman.setEnvironmentVariable(“Userid”, jsonData. userId);

This  parses the response body and assigns the value of ‘userId’ in the response data by creating an environment variable: ‘Userid’.

You can then pass the value ‘Userid’ in any of the next requests. An example below:

Assume 1172 is your user id in this request – https://productionserver.com/get/1172
You can use the environment variable as https://productionserver.com/get/{{UserId}}

Similarly you can use it in your request body as shown below:

{
“name”:”xyz”,
“userid”: “{{UserId}}”,
“label”: “Label2”
}

2.     Global Variables: Global variables provide a set of variables that are always in scope. You can have multiple environments, and only one can be activated at a time.  There is going to be one set of global variables that are always going to be available. You can use them in the same way as the environment variables- {{variableName}}.

Clear Global and Environment variables: You can always clear an environment variable or a global variable using the snippets below:

postman.clearGlobalVariable(“variable_key”);
postman.clearEnvironmentVariable(“variable_key”);

Tiny Validator for JSON Data

Tiny Validator helps you to validate the schema of your response. An example below:


 Response
 Test
 What the test does


{ “userId”: 123,
“fname”: “Prashant”,
“lname”: “Hegde”,
“username”: “admin@izent.com”,
“role”: “admin”,
“projects”: 0,
“phoneNo”: null,
}


var schema = { “items”: {
“type”: “string”
}
};
var data1 = [jsonData.fname,jsonData.lname];
console.log(tv4.error);
tests[“Valid Data1”] = tv4.validate(data1, schema);

Checks if the fname and lname are strings.
Similarly validates the  entire response schema.

Actually Postman is a really a time saver making it easier for developers to develop and test APIs. And when coming to testing of these API's it drastically reduces the pressure of regression testing from the QA team. API automated tests are far less time consuming than UI automated tests. The major advantage of API automation is that we can access the application without a user interface. This provides an early evaluation of its overall build strength before running GUI tests.

By integrating the API automated tests to the build server, the QA team can provide a quick feedback on the health of the application as soon as it is deployed. This is achievable with Newman, a command-line collection runner for Postman. It allows you to easily run a Postman collection directly from the command-line, and integrate it with your continuous integration server.

We shall discuss about Newman in the later topics. I hope this will give you a good start with the testing and automation of API's.

Well am not sure if you have reached here within 15 minutes as I said in the title but I hope this will  give you a good start with the understanding, testing and automation of API's.

Leave your comments/views below!

Friday, September 9, 2016

Dedicated to each testers around the world - Happy Tester's Day !!!

- No comments
Happy Testers day


Do you have any Idea on the importance of September 9 in a software tester’s life? Well, we will stop using our common term “bug” or “debug” and speak about the influential woman associated with this date.

Every day is Tester's Day for sure, but it's nice to have a day of our own, a special day that can bring all the testers around the world to share, collaborate and feel proud to be one.

Well! September 9 is celebrated as the World Tester's day.

The History

It was on September 9, 1947, that an American computer scientist and United States Navy Rear admiral Grace Murray Hopper noticed the first ever computer bug while working on the Harvard Mark II computer. Soon she traced a moth stuck between a relay in the machine. The first actual case of a “bug” was thus discovered.

The First Bug
The work they performed required some description, and the word had been found – «debugging» (literally: disposal of an insect) – and now it is used to describe the process of identifying and eliminating bugs which cause a computer to malfunction. The removed insect was pasted into the computer log with the entry: “First actual case of bug being found”, and was then transferred to the computer museum.


Since then, the process of identifying and removing bugs from computers was called testing. Subsequently “The Tester” – a completely new profession arose to meet this task.

Now a day's that has grown to a pretty big profession. Now there are Test Analysts, Test Engineers, Quality Analysts, Integration Test Engineers, Software Testers, Systems Integration Testers, Quality Assurance Analysts, Technical Test Specialists…and so on. The interesting fact is that all these designations have risen from a single BUG!

As every one knows, now software testers play with bugs and ensure that the computer software is flawless and of a high quality. Developers may view them as enemies but in reality, they have to thank testers for finding the bugs!! and making them appreciable for releasing a quality product at the end.

Testers don’t break software, software is already broken :)

Testers play a crucial role indirectly in website development by finding the bugs and making sure that everything is in proper working condition.

Hey guys and gals who are into Testing, Today is our day! Come let's celebrate !!!

Let this be our slogan, We do #lovetesting :)


Wednesday, August 3, 2016

Selenium 3 is finally released - First impressions of Selenium WebDriver 3.0.0 beta 1

- No comments

And now it's official. Selenium has released it's beta version of Selenium 3.0

 Let's go through some of the highlights of the Selenium road-map, which will enable the companies to find plenty of time to figure out what changes to implement in their test suites.

What are the changes going to be between Selenium 2.0 and Selenium 3.0?

One of the biggest change is that the old Selenium Core libraries will be dropped in 3.0. The focus will shift completely to the WebDriver API. 

For the last six years it has been advised to switch to the newer WebDriver APIs and to stop using the original RC APIs. With Selenium 3.0, the original implementation of RC has been removed, replaced by one that sits on top of WebDriver. For many users, this change will go completely unnoticed, as they’re no longer using the RC APIs.

How significant is the removal of Selenium Core?

Most users are already writing tests with WebDriver, so this change won't really impact those users. But for the users of Selenium Core, there may be some significant work ahead if they want to migrate to the future, supported versions of Selenium. They'll need to migrate their tests to WebDriver, but there are ways to preserve your existing investment in tests even if they're older Selenium Remote Control (Selenium RC) tests.

What is the background and status for the W3C WebDriver specification? What is the advantage of having a specification?

The WebDriver API has grown to be relevant outside of Selenium. It is used in multiple tools for automation. For example, it's used heavily in mobile testing through tools such as Appium and iOS Driver. The W3C standard will encourage compatibility across different software implementations of the WebDriver API.

There is a working draft available currently, and the working group hopes to have it finished by the end of the year.

After that first specification is complete and in the browser vendors' hands, work will start on W3C WebDriver Level 2, which will focus on testing standard web user notifications such as allowing geolocation or other, deeper level access through the browser, and access to the shadow DOM.

What are the important Changes?

* Minimum java version is now 8+

* The original RC APIs are only available via the leg-rc package.

* To run exported IDE tests, ensure that the leg-rc package is on the
  classpath.

* Support for Firefox is via Mozilla's geckodriver. You may download
  this from https://github.com/mozilla/geckodriver/releases

* Support for Safari is provided on macOS (Sierra or later) via
  Apple's own safaridriver.

* Support for Edge is provided by MS:
  https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

* Official support for IE requires version 9 or above. Earlier
  versions may work, but are no longer supported as MS has
  end-of-lifed them.
* New html-table runner backed by WebDriver.

* Unused command line arguments are now no longer parsed.
* maven packaging fixes

* Update GeckoDriver --port argument in all bindings

* System property webdriver.firefox.marionette now forces the server in marionette 
  or legacy firefox driver mode, ignoring any related Desired Capability.

* Grid fix NPE's on registration when -browser not specified.

 What are the changes to be done in using firefox driver ?
If you are using Selenium 3 then to work with Firefox browser you need to use separate a driver which will interact with Firefox browser. If you have noticed then we have done the same thing for Chrome and IE browser as well. One important thing in this post is even if you are using Firefox beta version then it will work. If you are using firefox 47 and so on then it will work.

Let us see how to use the Firefox Marionette Driver

Let’s run a basic program with Selenium 3 beta version

Program 1 without any driver


Output console

The path to the driver executable must be set by the webdriver.gecko.driver system property;

As you can see to work with Firefox we have to set the property now.  You can download the driver from Github and then you can extract and you will get .exe file.

Download URL – https://github.com/mozilla/geckodriver/releases/tag/v0.9.0

 Complete program for Firefox in Selenium using geckodriver

Now you can run the program and you will get expected output.

Firefox Marionette Driver, how to use the Firefox Marionette Driver, selenium, selenium 3, selenium webdriver

Thursday, July 28, 2016

How to find Xpaths using WebDriver Element Locator

- No comments
Finding/Writing XPath is one of the greatest challenge that most of the automation testers come across. In this post I am going to introduce a new plugin before you which will help you in finding the right XPaths just by a click.

This plugin generates different xpaths using xpath finding techniques. With the help of this you can easily generate xpaths for C#, Java, Python, Ruby.

For downloading this plugin for Firefox > Navigate to below url:
https://addons.mozilla.org/en-us/firefox/addon/element-locator-for-webdriv/

Once installed, you can navigate to any element and right click on that element which will generate xpath for that particular element. In the below image we have managed to find XPaths for the donate button.


Now I am sure that you have got much relief for the question:

How to find XPaths in Selenium :) 

Happy Testing !

Thursday, July 7, 2016

Must Know Visual Studio Keyboard Shortcuts

- No comments


In this post let me give you a short list of keyboard shortcuts for things you probably do often in Visual Studio. Many of them might be using these but still there are some who are not much familiar with using keyboard short cuts while programming.

Visual Studio Keyboard Shortcuts

Editor Related Keyboard Shortcuts

  • Ctrl + Enter   =   Insert blank line above the current line.
  • Ctrl + Shift + Enter   =   Insert blank line below the current line.
  • Ctrl + Space   =   Autocomplete using IntelliSense.
  • Alt +Shift +arrow keys(,,,  =  Select custom part of the code.
  • Ctrl + }   =   Match curly braces, brackets.
  • Ctrl + Shift + }   =   Select text between matched braces, brackets.
  • Ctrl + Shift + S   =   Saves all files and projects.
  • Ctrl + K, Ctrl + C   =   Comments the selected lines.
  • Ctrl + K, Ctrl + U   =   Uncomments the selected lines.
  • Ctrl + K, Ctrl + D   =   Do proper alignment of all the code.
  • Shift + End   =   Select the entire line from start to end.
  • Shift + Home   =   Select the entire line from end to start.
  • Ctrl + Delete   =   Deletes the word to the right of the cursor.

Debugging Related Keyboard Shortcuts

  • Ctrl + Alt + P   =   Attach to process.
  • F10   =   Debug step over.
  • F5   =   Start debugging.
  • Shift + F5   =   Stop debugging.
  • Ctrl + Alt + Q   =   Add quick watch.
  • F9   =   Set or remove a breakpoint.

Search Related Keyboard Shortcuts

  • Ctrl + K Ctrl + K   =   Bookmark the current line.
  • Ctrl + K Ctrl + N   =   Navigates to next bookmark.
  • Ctrl + .   =   If you type in a class name like Collection<string> and do not have the proper namespace import then this shortcut combination will automatically insert the import.
  • Ctrl + Shift + F   =   Find in Files.
  • Shift + F12   =   Find all references.
  • Ctrl + F   =   Displays the Find Dialog.
  • Ctrl + H   =   Displays the Replace Dialog.
  • Ctrl + G   =   Jumps to the line number or go to the line.
  • Ctrl + Shift + F   =   Find the references of the selected item in the entire solution.

Navigation Related Keyboard Shortcuts

  • Ctrl + Up/Down   =   Scrolls the window without moving the cursor.
  • Ctrl + –   =   Take cursor to its previous location.
  • Ctrl + +   =   Take cursor to its next location.
  • F12   =   Go to definition.

Project Related Keyboard Shortcuts

  • Ctrl + Shift + B   =   Build your project.
  • Ctrl + Alt + L   =   Shows Solution Explorer.
  • Shift + Alt + C   =   Add new class.
  • Shift + Alt + A   =   Add new item to project.
You can go through the complete list of shortcuts here

Tuesday, July 5, 2016

How to find all links on a web page using selenium webdriver C#

- No comments


Sometimes we may need to find some tricky actions on software web applications. Selenium webdriver do not have any direct method to perform any such tricky actions. So we may need to use some tricks in our webdriver test script to enable us to perform some actions on the required web applications. Today let's discuss about how to find all links on a page using selenium webdriver C#

You can use the following method to find all links on a page using selenium webdriver C#

Below is the code which finds all the links on a webpage. We are navigating to a link using Firefox. Next we get all "A" tags using FindElements and iterating through those using ForEach loop.