Thursday, September 22, 2016

Code Resuablity & Maintainablility Using Action Methods in Selenium Webdriver

In this post I'm going to share kind of coding pattern which is very helpful in maintaining our automation code. This post is written insight to help beginners. We'll learn that instead of writing a linear script, we should create action methods (functions) which in general contain actions which we are going to performing on our web software.

Let's say, we have a login functionality in our software and we have to automate it. In that case we'll create a method named login and write the commands like, entering username, password and click login in that method. Now we can use that method wherever we need it in other test cases as well. Benefits of using action methods are:

  • Code Reusability
  • Better maintainability of code
Sharing below a sample script, in which I'm entering data in a web form using action methods:




Feel free to ask queries. Happy Coding :)


@uthor 
Vaneesh Behl
vaneesh.behl@gmail.com


Tuesday, August 2, 2016

TECHLISTICSPACE  covers Automation Testing & Tools, Mobile Automation, Selenium Webdriver, Sikuli, Robot Framework, Appium, Java, TestNG, JUNIT, JENKINS, Automation Frameworks etc.


Blog Sections:

                                                       

Appium For Mobile Automation



 Selenium Webdriver
                            Sikuli - An Image Based Automation Tool      





Java Stuff                                           Robot Framework






More Stuff                           TestNG






Tuesday, July 19, 2016

Selenium Essentials - Become Expert in Selenium Automation

Folks, I thought of sharing Selenium Essentials which you must cover if you want to get expertise in Selenium Automation. It might help beginners and intermediate techies. I have divided the content in to two parts, Basic and Advanced. And I have linked the content to other web links of the blog, and planning to cover all in my future blog posts, and link all the contents periodically. Find below the Selenium Essentials:

Course is divided into two Parts:

PART 1 - Basic Selenium which teaches you about Selenium IDE – Record and Play, Debug, Verification points and XPATH.

PART 2 - Advanced Selenium using Java which teaches Java/JUnit, Eclipse IDE, Selenium RC, Data Driven Testing, Ajax based application Testing.


1) Manual Testing Concepts
2) Software Development Life Cycle
3) Automation
3.1 Introduction to Automation
3.2 Test Automation of Web Application


PART I

1) Selenium Overview
2) Introduction to Selenium
3) Selenium IDE Basics
3.1 Getting Started

4) Selenium IDE
4.1 Introduction of Selenium IDE
4.2 Installing Selenium IDE
4.3 Starting Selenium IDE 
4.4 Selenium IDE Commands 
4.5 Writing Sample Test Case 
4.6 Running Selenium Tests on Different browsers

5) Tools for Writing Test Cases
5.1 Introduction
5.2 Overview and Usage of tools.
  
6) XPATH & Regular Expressions
6.1 Introduction to XPATH
6.2 Tools (Firebug & Firepath)

7.1 Recording and Running
7.2 Editing and Debugging.
7.3 Verifying Page Elements – Assertions and Verifications.
7.4 Locating Elements
7.5 Matching Text Patterns.
7.6 Store Commands and Selenium Variables
7.7 JavaScript and Selenese Parameters
7.8 Handling Alerts, Popup and Multiple Windows.


PART II

1) Selenium Webdriver
1.1 Webdriver Architecture

2) Eclipse
2.1 Installing Eclipse
2.2 About Eclipse IDE
2.3 Preparing Eclipse
2.4 Java Project (Classes, JUnit Classes) Editors, View and Perspectives
2.5 Simple Project 
2.6 Importing and Exporting
2.7 Eclipse Features
2.8 Debugging using Eclipse
2.9 Installing Eclipse Plug-in


3) Junit

3.1



About JUnit.
3.2
Test Fixture.
3.3
Sample JUnit Test Cases.
3.4
Test Runners.
3.5
Working with Test Case.
3.6
Working with Test Suites.
3.7
Testing Exception Handling.
3.8
Exercises and Examples.
3.9
JUnit 4




4) TestNG             
4.1 Annotations - @BeforeClass, @BeforeTest, @BeforeMethod, @Test 
4.2 Annotations - @AfterClass, @AfterTest, @AfterMethod
            4.4 Priority
            4.5 testNG.xml
            4.6 Groups          



Feel free to share your views/queries. Happy Learning :)




@uthor 
Vaneesh Behl
vaneesh.behl@gmail.com

Friday, July 15, 2016

Mobile IOS Automation Part 1 - Appium Configuration with MAC

In recent days I got the chance to work on a Mobile Automation assignment. I got enough time for hands-on. I didn't have much experience on mobile automation before. I thought of sharing installation steps for Appium on MAC. I pen down all the configuration details and sharing below, so others could take help from it:


MAC Configuration with Appium

List of downloads:-
1.        Download Appium version 1.XX (.dmg) file      from https://bitbucket.org/appium/appium.app/downloads/
2.        Download Appium-master from https://github.com/appium/appium/
3.        Download latest android sdk.
4.        Install latest Xcode
5.        Update Android sdk with
a)        Latest API level
b)        Android SDK Build tools, SDK tools and SDK platform-tools from tools
c)        Google USB driver and Google Web-driver from extras.
6.        Download safari-launcher from https://github.com/budhash/SafariLauncher for mobile web testing in iPhone.

Environment variables : -
1.    Open terminal
2.    vi .bash_profile 
3.    press 'i' and  enter these export commands
a)              export ANDROID_HOME=android sdk path
b)              export PATH=$ANDROID_HOME/platform-tools:$ANDROID_HOME/tools:$PATH
c)              press Esc key.
4.    ‘Shift’ + ’:’
5.    wq > enter
6.    re open terminal.

Installing IOS_Web_PROXY
1.      open terminal and enter these commands
 > ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"
 > brew update
 > brew install ios-webkit-debug-proxy

Installing safari-launcher in iPhone
l  Require Apple account linked with developer program
l  Add device to developer program
l  Launch the Safari-launcher.app on connected device from Xcode.

Pre-Script Steps In terminal
·         ios_webkit_debug_proxy
·         cd
·         ./bin/ios-webkit-debug-proxy-launcher.js -c:27753


Configuring Appium from its source code
l  npm install appium@1.4.16
l  Run this bin/appium-doctor.js from installed appium folder
l  Copy .git folder from cloned appium (git clone https://github.com/appium/appium.git)
l  Navigate to appium folder and execute ./reset.sh)
l  Provide path of installed appium source code in “Use External Appium Package” in appium UI under Developer setting.
l  Troubleshooting
n  If error related to ideviceintaller :- Execute brew install --HEAD ideviceinstaller  

n  If error related to provisional profile :- Execute ./reset.sh --ios --ios-safari after navigating to installed appium folder.



@uthor 
Vaneesh Behl
vaneesh.behl@gmail.com





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.





2. HTTP://AUTOMATIONPRACTICE.COM/

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.





3. HTTP://WWW.WAY2AUTOMATION.COM/DEMO.HTML

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.





4. HTTP://NEWTOURS.DEMOAUT.COM/

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.

 


6. HTTP://DEMOQA.COM/

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 :)




@uthor 
Vaneesh Behl
vaneesh.behl@gmail.com
http://vaneeshbehl.branded.me/                                                                                                                

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 :)


@uthor 
Vaneesh Behl
vaneesh.behl@gmail.com

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.


Output:

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
vaneesh.behl@gmail.com