Monday, 30 September 2013

WebDriver Script in C#

Guru(s)/Reader(s), we have seen the introduction of Web Driver and its installation with C# in my previous articles. Now, we are going to code our First Web Driver Script in C#.

01.Navigate to Google Home page.
02.Enter some Url in the Search box.
03.Verify the result.
04.Close the browser before ending the entire program.

WebDriver Code: 
using System;
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Support.UI;

//OpenQA.Selenium - Contains the WebDriver class needed to instantiate a new browser loaded with the specific browser. Here we used, Firefox browser.
//OpenQA.Selenium.Firefox - Contains the FirefoxDriver class needed to instantiate a Firefox specific driver onto the browser instantiated by the WebDriver class.
//We can include more namespaces based on our requirement like, manipulating external files,taking screen shots etc.

namespace ConsoleApplication1
    class FirstWebDriverScript
        static void Main(string[] args)
           //Declaration of application related variables.
            String _baseUrl = "";
            String _boxGoogleSearch = ".//*[@id='gs_htif0']";
            //Create a new instance of the Firefox driver,Observe that the above Firefox  class has no parameters. It means that the default Firefox profile will be launched by the program. The default Firefox profile is similar to launching the Firefox in safe mode(i.e., no extensions).
            IWebDriver idriver = new FirefoxDriver();
            //Navigate to the page

            //Maximizing the browser Window
            //Searching for the Google Search box by using XPath
            IWebElement _googleSearch = idriver.FindElement(By.XPath(_boxGoogleSearch));
            //Entering the search string in Google Search Box
            //Comparing the title with the expected value
            if (idriver.Title.Contains("software-testing-community"))
                Console.WriteLine("Test passed");
            else {
                Console.WriteLine("Test Failed");

           //Closing the Browser

            //Releasing all application-defined tasks with freeing, releasing, or resetting unmanaged resources.

The WebDriver's code and its explanation is included as part of the comments. Please feel free to add your comments/ suggestions.

Friday, 27 September 2013

Introduction to Selenium WebDriver

This article gives the details about the WebDriver. 
WebDriver is a Web Automation tool which is used to run the Tests across different browsers[Ex: IE, Firefox,Chrome, Opera etc.]. WebDriver is the new feature in Selenium 2.0.WebDriver also allows/enables us to user different programming languages like Java, .Net, Ruby,PHP, Python and Perl in creating our test scripts.
It’s not mandatory to work all the above mentioned programming languages to work on WebDriver. We just need to be knowledgeable on anyone of the programming language.

WebDriver’s Architecuture:
WebDriver has a very very simple architecture. The following picture depicts the WebDriver’s architecture.

WebDriver controls the Browsers from OS level. The main required thing is that the programming language’s IDE should contain the Selenium commands and a browser.

WebDriver Features:
  • WebDriver is faster as it directly speaks to the browser as well as the uses the browser’s engine to control the same.
  • WebDriver interacts with the application’s elements in a realistic way. WebDriver can’t really enter a value in a Textbox/ Text area if it’s disabled on the web page that we’re testing.
  • WebDriver’s API is very simple as well as easy for understanding. Because, it doesn’t contain redundant and confusing commands.
  • WebDriver can drive an invisible browser called HtmlUnit.
HtmlUnit: HtmlUnit browser is called as “Headless” / Invisible browser as it doesn’t have the GUI. Generally it’s very fast as it doesn’t waste the time in loading page elements. It’ll be helpful in executing the Test for n-number of cycles in a quick period of time. HtmlUnit can be controlled via Automation only as it’s invisible.

WebDriver has certain limitations.
  • WebDriver has no built-in command that automatically generates the Test Result Report/File. We need to rely on the IDE’s output window or write our own code to generate the report as per our requirement. For example, we can customize our output in the form of HTML, Excel or Notepad etc.
  • WebDriver can’t readily support the new browsers. As we know that the WebDriver operates on the OS level. We know that the each browser communicate with the OS in different ways.  The new browser may communicate with the OS in a different process than the old process followed by the older version of the same browser. So, the WebDriver team need take a decision and work towards it to support the new version.

WebDriver With C#

This article explains the steps to be followed to setup the Selenium WebDriver with C#.
 Prior to Selenium 2.2.0, all Selenium C# bindings were distributed as unsigned dlls. But, currently, the C# Bindings are distributed as the signed DLLs along with their dependency DLLs.
The following steps to be followed to setup the Selenium WebDriver with C#.
  • The C# bindings(named as “”) can be downloaded from .
  • Launch Microsoft Visual Studio and navigate to File> New> Project and observe that the following window is opened.

  • Select Class Library from the list and enter the Soultion name as “WebDriverWithCS” as shown in the above picture.
  • Right click on the Solution name “WebDriverWithCS” in “SolutionExplorer” and click on “Add Reference” option and observe that a Window is opened to select the DLLs as shown  below.
  • Click on the Browse button and traverse to the path where the unzipped files[Step#01] are placed, and select all the files and the click on “OK” button.
  • Observe that the Dotnet DLLS are added and displayed under  “Solution Explorer”> Solution name()> References” section as shown below.  
  • Just type the following lines of code just above the namespace.
                 using OpenQA.Selenium;
                 using OpenQA.Selenium.Firefox;
                 using OpenQA.Selenium.Support.UI;
Now we are set to write our Selenium C# script on Firefox.

Please feel free to add more comments to this article.

Thursday, 26 September 2013

Difference between Selenium IDE, Selenium RC, Selenium Webdriver

This articles explains the basic differences between the Selenium IDE,Selenium Remote Control Server and Selenium WebDriver.

S.No Selenium IDE Selenium RC Selenium WebDriver
  1 Only works on Firefox. Works almost on all browsers.(IE,Opera,Firefox,Chrome).But doesn't work on the latest version of IE and Firefox. Works on all versions of IE,Firefox,Chrome,Opera.
  2 Supports Record and Playback. Doesn't support Record and Playback. Doesn't support Record and Playback.
  3 No Server is required to start. RC Server is required to start. No Server is required to start.
  4 JavaScript based Core Engine. JavaScript based Core Engine. Interacts natively with all browsers.
  5 Simple to use. It requires knowledge on JavaScript if User extensions are used,which makes the work little bit tougher. Simple and small API. Complex and a little bit large API when comparing with RC.
  6 Not at all Object Oriented. Less Object Oriented API. Purely Object Oriented API.
 7 Can't move mouse cursor with this. Can't move mouse cursor with this. Can move mouse cursor with this.
 8 No listeners. No listeners. Implementation of listeners are provided.
 9 Full XPath of the elements need to be appended with 'XPath =\\' syntax. Full XPath of the elements need to be appended with 'XPath =\\' syntax. No need to append the full Xpath of the elements.
 10 iPhone Applications can't be tested. iPhone Applications can't be tested. iPhone Applications can be tested.
 11 Android Applications can't be tested. Android Applications can't be tested. Android Applications can be tested.

Please feel free to write your comments as well as please let me know if I missed/misinterpreted on anything :).

Tuesday, 17 September 2013

Tips to be a Champion Tester

As we know that the Testers always feel tremendous pressure when the product release is around the corner. Product Release is a milestone for any Tester irrespective of the amount of Testing have been conducted. So, it’s all about testing well in a tough situation and delivering a quality product which in turn will be shipped to the client. It’s when we have to find and report all the issues in the application and get it fixed by the Development team.
We know that the Testing is important throughout the SDLC. But it suddenly becomes the most important activity of all, once the product is getting ready to be released. So, the pressure mounts on the Testers to some extent. So, it needs lot of skills and experience to handle such kind of situations.
We need give more attention to the following areas during such kind of situations.
Find out the improper/missing functionality and get them fixed by the Development Team as soon as possible. 
Crash Issue:
Generally the product will not be accepted if the software is getting crashed itself or crashing the user’s system. So, we should test all scenarios that may cause the system crash. For example, we need to test the scenarios like Memory Leaks, DLLs, missing files due to bad 3rd party installer etc.
Smoke Test:
Smoke Testing to be conducted on daily basis to find the new problems and get it fixed.

Usability Errors:
Execute all possible navigation paths in your application to catch the Usability errors. 

Bugs/Test Cases/Bug Fixes tracking:
We need to regularly keep track on the priority bugs/test cases/bug fixes. This ensures that the important bugs are dealt first.
Recover Testing:
Recovery scenarios may not be handled properly in some of the applications which will lead to the loss of the data or inconsistent results.So, we should make sure that the recovery scenarios are executed properly. 
Regression Testing:
Regression testing to be conducted on the related modules whenever the issues are fixed.It’ll be helpful in avoiding the major issues at the final moment.
Cross Verification With Team(Peer Review): 
Some fixes may not be clear to a particular Testers. It’s always to have a 3rd eye on such kind of areas to avoid unnecessary issues during the latter part of the product release.
Deferred Issues:
Sometimes the organization used to defer some of the issues. Such kind of issues need to be handled in the future releases. So, we should make sure that the issues deferred in the previous release are fixed in the current release.
The above items are generic list. Please feel free to suggest more points :) .

Monday, 16 September 2013

Cheat Sheet For Website Testing

Website Testing is still a confused topic among the Testers, even though a lot has been discussed and written about it. There is lot of articles about the Website Testing. This article is not attempt to explain what needs to be covered as part of Website Testing. It’s just to make you understand that there is no universal rule to testing that can fit all kind of similar testing assignments.

You can use the following Checklist as cheat-sheet for Website Testing.

Functionality Testing:

The following areas need to be covered while doing testing the Functionality of a website.
[01]. Links/ URL Testing:
There are mainly 4 types links/URL needs to be tested on a web page.
  • Internal Links [Test the links that points to the pages on the same website.]
  • External Links [Test the links that points to the pages on a different/external website.]
  • Broken Links [Test if any of the links are broken or dead]. There are n-number of tools available to check the broken links on a website/page. We can use Broken Link to test the broken links on Websites/Blogs etc.
  • Email links[Test if the Email link opens the default mail client with the recipient email id is already filled in the “To” field.
[02]. Forms Testing:Web forms should be consistent and should contain all the required input and output fields. The integrity and consistency should be tested on the web forms. 

[03]. Error Testing:

Error messages are the integral part of the Developed websites. Error message should guide the user when a wrong input is submitted in such a way that the user can easily understand the actual issues on the input submitted.
[04]. Mandatory & Optional Fields Testing:
Test whether the forms on the websites handles the mandatory and optional fields efficiently.The application should not allow to proceed unless ALL the mandatory fields are not filled.We also need to make sure that all mandatory fields are marked with asterisk(*). Likewise, the system should allow to proceed irrespective of the values filled in optional fields.

[05]. Validation Testing:
Tests the fields on the forms for field level validation.Test and validate the user inputs like ComboBox, TextBox,Dropdown List selections, KeyUp, KeyDown,KeyPress etc.

[06]. Database Testing:
Most of the websites are developed with the back end database. We need to test the integrity of the database to make sure that the website is able to process the data effectively.

[07]. Client Side Testing:
We need to test the temporary files stored on the client system. This type of Testing is conducted to make sure that the sensitive information like Password are saved without being encrypted or other readable forms.

[08]. Cookies Testing:
A Cookie is a small information that is stored on the client's machine by the Server. Later, it'll be used by the Client machine's web browser to retrieve the information about the website. Generally Cookies contains personalized user data or information that is used to communicate between different web pages.

Cookies testing to be conducted to make sure that the personalized data or information or saved in a secured way.
[08]. Speed Testing:
The website should load on any kind of network ie., the response of the application should be consistent irrespective of the internet speed.

[09]. Usability Testing:
The website should be easily accessible.Assume that we are developing a website with lot of difficulties to the user to navigate to each page. Then the website won't be much use for a user. We need to keep the following criteria in our mind while doing usability Testing.
  • Navigation.
  • Learning about the features.
  • Look and feel.
  • Easy accessibility.
  • Satisfaction. 
[10]. Web Security Testing:
Web security testing is also called as Penetration Testing. Security Testing to be conducted to identify the security issues/vulnerabilities and repair/remove them.
For example, we can can take file upload functionality to a website. The website should have the automated scanned software to scan and make sure that there is no virus in the uploaded file.It should also have an option to disable the virus if there are any.

[11]. Compatibility Testing:
Compatibility Testing to be conducted to test the adequate rendering of the application across different browsers(IE,Safari,Mozilla, Firefox, Chrome etc) and Operating Systems(XP,Windows 7, Vista, Linux, Mac etc.).

We need to consider the different OS versions, hardwares, screen resolutions etc. We need to make sure that the following points are covered when doing the Compatibility Testing.
  • Various Browsers.
  • Various window sizes.
  • Various font sizes.
  • By disabling/enabling the Javascript/ CSS.
  • Browsers with pop up blockers enabled/disabled.
  • Various operating systems.
  • Hard drives with less/more memory spaces.
  • Various network environments.
 I hope this articles explains the areas to be tested when Testing a web based applications. Please feel free to write your valuable comments about this article.

Tuesday, 10 September 2013

Introduction to Selenium,Selenium IDE, Selenium Remote Control Server

This article gives the introduction to Selenium, Selenium IDE and Selenium Remote Control Server.

  • Selenium is a popular open-source automation suite for Web Applications.
  • Web Applications can be tested across different browsers as well as platforms.
  • Selenium is similar to QTP but it mainly focuses on the Web based applications.
  • Selenium is not a single tool. It’s a suite of softwares, each catering different needs of an organization.

Selenium has the following four components.
  • Selenium Integrated Development Environment(S-IDE)
  • Selenium Remote Control(RC)
  • Web Driver
  • Selenium Grid

Selenium Integrated Development Environment(S-IDE):

S-IDE is the simplest Selenium Framework as well as easy to learn. It’s just a Firefox plugin which can be installed like other Firefox plugins. This plugin can be used as a prototyping protocol due to its simplicity. We need to use either Web Driver or Selenium Remote Control if need to create more advanced Test cases.

S-IDE has its own advantages and disadvantages.

  • Easy to install.
  • No programming experience is required.
  • Can export the tests to formats usable in Web Driver or Selenium Remote Control.
  • Have support to extensions.
  • Available only in Firefox.
  • Designed to create only prototype of Tests.
  • Test execution is very slow when comparing with Selenium Web Driver / Remote Control.
  • No support for iterations.

 Introduction to Selenium Remote Control (RC):

This is first Web Automation tool which allowed the users to use the programming language they prefer. As of now, RC supports the following programming languages.

  • Java
  • C#
  • Python
  • Perl
  • Ruby
  • PHP

Advantages of RC:
  • Faster execution of Test cases than IDE.
  • Can support multiple browsers and platforms. 
  • Can perform conditional and looping operations.
  • Supports Data Driven Testing. 
  • Has the complete API.

Disadvantages of RC:

  • Installation is complicated than S-IDE. 
  •  Programming knowledge is required. 
  • Needs selenium RC Server running all the time to execute the tests. 
  • Browser interaction is less realistic. 
  • Inconsistent result & User JavaScript. 
  •  API consist redundant and confusing commands.

The details about Web Driver and Selenium Grid are explained in a separate article.

Back To Top