Tuesday, June 28, 2016

Top 6 Demo Websites For Practice Selenium Webdriver

All Selenium beginners come across a question that for which website they should start writing automation code for practice. I have seen most of the beginners start writing selenium code for Gmail, Facebook, Linkedin like websites straight away and land themselves in trouble when their code don’t work more than once, reason being dynamic nature of page elements of these websites. I always discourage beginners from practicing their Selenium skills on gmail, fb like websites. These websites has dynamic page elements which are constantly changing which they intentionally implemented to discourage automation of their website to avoid fake or bot (robot) accounts. They don’t want to allow a selenium script to create an account on their website and block storage on their database as they are going to make profits from human accounts only.

So, in this post I’m going to share URLs of some demo websites which Selenium beginners can use for practice purpose. Here is the list of demo websites:

This is a brilliant online resource to learn and exercise Selenium webdriver. You can prepare test scripts, test data, and object properties accordingly. It provides you with multiple options, listed few of them below. Please note that the demo usernames and passwords are available on the demo page.
§  http://www.phptravels.net/ – it offers a web page where you can test online booking for hotel, flight, tours and travel. It even lands you a login page which takes email id as the user name.
§  http://www.phptravels.net/admin/ – Here you simply can do sign-in, opt to reset and even notify for a lost password.


It’s a full featured e-commerce website simulator and my favorite. Here you can test anything from a simple login page to product selection and add/edit your shopping cart. It covers the complete online shopping workflow. You can write Selenium scripts to fill address, shipping details, and proceed to simulate payment.


Another awesome website to practice Selenium webdriver online. It gives you so much to test that whatever we write but it would feel incomplete. Still check out the below list for a quick reference.
§  Interactive web operations – You can test operations like draggable, droppable, resizable, selectable and sortable.
§  Online widget testing – You can play with autocomplete list of options, handle date picker, tabs, and sliders.
§  Miscellaneous items – It’ll prompt with a variety of frames and windows. And will also present dropdowns and alert boxes.


It asks you to log in first before presenting the online flight booking web page. The demo username/password is test/test.
§  http://newtours.demoaut.com/mercuryreservation.php – It has a Flight Finder to search for the lowest fare on different airlines. You can try to book a flight, and can set preferences for economy/business.

It is a lightning fast demo website to practice Selenium webdriver online. Here you can perform the following web operations.
§  http://thedemosite.co.uk/addauser.php – Presents a web page to add a user. It displays the success/failure message on the screen.
§  http://thedemosite.co.uk/login.php – It will give a login screen with username/password fields. You can use the “test” as username and “test” as the password.



This is an excellent site for online Selenium practice. It has a rich set of web UI functions specially designed to the needs of testing of web application of all types. Some of the notable operations on the web elements that you can perform are.
§  Online registration – fill the registration form and submit.
§  Interactive actions – Draggable, resizable and selectable etc.
§  Widget functions – Autocomplete, slider, menu and date picker etc.
§  Misc stuff – Testing with different frames and windows.

Feel free to share your views.

Happy Learning :)

Vaneesh Behl

Friday, June 17, 2016

How To Take Partial Screenshot in Selenium Webdriver

Folks, sometimes we don't want to take screenshot of the full screen and inspite of the particular element due to some reasons. Reasons might be, full size images would last in huge memory storage for image directory or sometimes we need to take element specific screenshot due to test case requirement which makes more sense.

Sharing Webdriver's code snippet for taking partial screenshot below:

Feel free to share your views in comments. Enjoy and Happy Learning :)

Vaneesh Behl

Wednesday, June 8, 2016

To Use Dependencies with Selenium Webdriver's Test Methods in TestNG

TestNG is a testing framework developed in the lines of JUnit and NUnit, however it introduces some new functionalities that make it more powerful and easier to use.
TestNG is designed to cover all categories of tests − unit, functional, end-to-end, integration, etc., and it requires JDK 5 or higher. We Automation Testers make use of TestNg to execute our tests. And it also provides some cool features in the form of parameters of annotations, one out of which I'm going to cover in this post.
                                                             TestNG provides a way to manage dependencies with annotations. For this testNg provides "dependsOnMethods" parameter for @Test annotation. If you have declared dependency of one method on second, then first of all second method will be executed and then after first method. 
Below is the code snippet:

In above code, method SignIn() is dependent on OpenBrowser() and method LogOut() is dependent on SingIn and OpenBrowser methods. 

Below is the execution sequence of above code snippet:

1. OpenBrowser
2. SignIn
3. LogOut.


This will execute first (Open Browser)
This will execute second (SignIn)
This will execute third (Log Out)

Feel free to share your thoughts and views. Enjoy :)

@uthor - 
Vaneesh Behl

Monday, June 6, 2016

A Guide To All Selenium Webdriver Commands

While working with Selenium Webdriver, I thought of sharing a script having almost all webdriver commands. The script I'm sharing is having different ways to use the same command. Hope it helps.

What is WebDriver? WebDriver is now an official W3C Specification, and in-short, it is a method of interacting with a web browser. Previously, with Selenium RC, Selenium would operate with the browser by injecting JavaScript to interact with elements. With the adoption of WebDriver, browser manufacturers like Google, Mozilla, and Microsoft release their browser with the ability to be controlled by a hook, that Selenium can tap into. This hook enables Selenium to interact with the webbrowser in the same way that humans do.
Here are the Selenium Webdriver commands:

Thanks for reading. Do share your thoughts and comments.

Happy Learning :)