Thursday 9 April 2015

Setting up Selenium WebDriver Environment for first Automated Script

Lesson 4- How to set environment and how to automate Web Applications with Selenium WebDriver.
To write automated scripts with Selenium Web Driver we must have coding knowledge of any programming language like java,C#,python so on.
Before writing scripts we must know these questions.What is difference between Selenium IDE and Selenium WebDriver? What are the requirements to automate any web application? What are the advantages of the Selenium WebDriver? Which language is best with automation? Come back to our topic supposing that you know answers of the asked questions.Let's start setting environment and Web application automation with Selenium Driver.

Here I will prefer Selenium WebDriver Integration with Java language and following requirements are necessary for Automation.

  • JDK (java development Kit)
  • Eclipse IDE
  • Selenium WebDriver library
  • Selenium IDE
  1. How to download and install Jdk?
Go to here to download latest version of the Jdk w.r.t your Operating System.After successful downloading of jdk run the .exe file to install the java development kit(Jdk).

  •  How to set Java_Home path variable on Windows?

Go to the Properties of My Computer>Advance System Settings>Environment variables> then click on the New for adding Environment variable.


Setting Java_Home
 Type Java_Home in the Variable Name and insert your jdk installed path in the variable value like 'C:\Program Files\Java\jdk1.7.0_71\bin;' then edit the Path variable similar to given below screenshot.

 
Editing path variable

 Now to verify the jdk/java installation follow the instructions here.

2-How to download and install the Eclipse IDE?

Go to here to download latest version of the eclipse IDE after successful download extract the zipped file at any location and open the eclipse.exe for accessing the IDE environment,first time you also need to set the workspace.

Selenium WebDriver with java

Now on eclipse click on the File and create new java project.


Create New Java Project



Now open your Selenium IDE Exported script in the notepad (As we have discussed earlier about the Selenium IDE installation,recording scripts and exporting scripts).


Exported script opened in NotePad
Right click on the eclipse project and create a package with name 'com.automation.first'.


Creating New Package
Right click on the package 'com.automation.first' then select New >Class with name "Google Automation".


Created Automation Google class

Now Copy the exported script and paste in the 'Google_Automation' class.


Google_Automation class with exported script
Notice that lot of errors are displaying because no supported library/Jar file has been added in the project, for downloading Selenium WebDriver libraries click here  then Scroll to the Selenium Client and WebDriver language Bindings section.Press on the download link to start downloading w.r.t your language, here I am going to download Selenium Webdriver for java because i am binding Selenium with java if you wish to bind with the C# then download Selenium WebDriver for C#.


Downloading Selenium WebDriver Libraries

After successful downloading of the Selenium WebDriver libraries, extract the selenium-java zip file at any location,then go to your eclipse IDE Right click on the project >Build Path>Configure build Path>Add external jars.



Add External Jar Files
Select both of the Selenium WebDriver jar files from folder 'Selenium-java-2.45.0' and also all jar files of the lib folder and press on the OK button.



Selenium WebDriver lib added


after adding selenium web-driver jar files no more errors are displaying and we are ready to execute script.Right click on the 'Google_Automation.java' class then  Run as Junit Test during script execution make notice of  Firefox Driver initialization then opening Google site after that closing the site.

Running Selenium WebDriver Script



Driver initialization

Note:This simple tutorial covers how to utilize selenium IDE Exported script in Selenium WebDriver.How to run the Selenium WebDriver scripts,How to set the Selenium WebDriver Environment, In the future posts we will discuss Selenium WebDriver with deeper concepts.








Tuesday 7 April 2015

How to Export Selenium IDE Scripts

Lesson 3- How to Export Selenium IDE Scripts.

As we have already covered recording and playing automated scripts with Selenium IDE now we will cover How to export Selenium recorded scripts? after this post we will focus on How to Integrate exported scripts with programming language and How to automate website with Selenium WebDriver.

1-How to Export Recorded scripts?
Open the Selenium IDE and Select your recorded testcase (How to record scripts with Selenium IDE click here, Open script if it is already recorded),Go to the File then option Export Testcase As then select your favorite programming with testing framework here i will export As java/Junit4/WebDriver. see screenshot
                  

During export you need to provide naming convention and destination for the exported file after that pressing on the save button will export script in your selected programming language and testing framework.Now open the exported and found the Selenium IDE recorded scripts written in the programming language .see screenshot 




Monday 6 April 2015

Automation with Selenium IDE

Lesson 2- Automation with Selenium IDE.


As we have already discussed about Selenium IDE in our first lesson now in this lesson we will cover how to Install Selenium IDE and how to record and run the Selenium scripts, after that we will cover how to integrate selenium scripts with programming languages.

1-Selenium Installation Guide-

  • Before the installation of Selenium IDE make sure Firefox is installed because Selenium IDE is implemented as a Firefox extension.In case Firefox is not installed on your PC you can follow given URL for downloading Firefox latest version https://www.mozilla.org/en-US/firefox/new/ ,After downloading follow steps for installation with respect to your Operating System. 
  • Suppose you have installed Firefox / It is already installed Now Go to following URL http://www.seleniumhq.org/download/ for downloading/implementing Selenium IDE with your Firefox Browser. 
  • After opening the given URL Download the latest version of the Selenium IDE and mark permission Allow. see given below screenshot                                                                                                                     




  • Now press on the Install Now for installation.see given below screenshot    


  • After Successful installation Restart your browser and Verify that Selenium IDE plugin is installed / Integrated with your browser.For verification Open your browsers Menu then Add-Ons and verify selenium add-on in the list. see given below screenshot



2-Recording first Script with Selenium IDE-  
        After successful installation now we are ready to write/record automated scripts for web testing.
For first automation i have chosen Google site because every one is familiar and accessible this site.

Steps to created automated scripts. 
  • Click on the Selenium IDE button from the browsers toolbar and interact with the Selenium IDE scripts recorder tool.see given below screenshot where i have highlight main functionalists which we will perform.                                                                                                                                              




  • Rename your testcase name to 'Google Automation' then press on the Recording button.
  • Now open the Google site and type in the search like 'Automation testing' then Stop the Selenium IDE recording and observe that script has been recorded for the Google site. see given below screenshot                                                                                                                                        
  • After playing the entire suite you will see that script will open 'www.google.com' in new tab then will type the 'Automation testing' in the search box.  
  • Before closing Selenium IDE save your test suite at any location which can be executed later by opening in the selenium IDE.                                                                                                                                                                                                                                                             Note:  Keep visiting We will soon cover the Exporting Selenium IDE Scripts,Selenium WebDriver Scripts with java languages.




Thursday 2 April 2015

Difference between Selenium IDE and Selenium WebDriver

Lesson 1- Introduction to Selenium and Selenium WebDriver.

Selenium:Selenium is an open source testing tools such as HP Quick Test Professional. This tool is very useful to test web applications; it comes with a small script recording tool known as Selenium IDE. Selenium IDE records the user activity on the web application  and the recorded scripts can be played later for testing / recorded scripts can be integrate with popular programming language like java,python and c# (we will discuss later with languages).These recorded scripts are referred automated testing.

Selenium WebDriver: The primary new feature in Selenium 2.0 is the integration of the WebDriver API. WebDriver is designed to provide a simpler, more concise programming interface in addition to addressing some limitations in the Selenium-RC API. Selenium-WebDriver was developed to better support dynamic web pages where elements of a page may change without the page itself being reloaded. WebDriver’s goal is to supply a well-designed object-oriented API that provides improved support for modern advanced web-app testing problems.


Difference in Selenium IDE /WebDriver:
Selenium IDE behaviors.

  • Works only on Mozilla
  • Record and Run Tool
  • Server is not required to run like Selenium RC
  • Not Object Oriented
  • Does not records the mouse hovers behaviors
  • Requires full Xpath for finding elements like(xpath="\\html\div[2]\input")
  • Mobile Testing can't be performed
Selenium WebDriver behaviors.
  • Works on the all browsers (Firefox,Chrome,IE etc)
  • No IDE Server is required for the Firefox browser
  • IDE server is required for other browsers  like(Chrome,IE and Opera)
  • Object Oriented purely
  • Mouse behaviors can be scripted like(Mouse hover)
  • Better reporting with help of Junit ,TestNG and Nunit)
  • Mobile testing can be performed
  • JavaScript can be integrated with scripts