A closer look at Selenium

Introduction to Selenium

Selenium is an open source Software used to automate Web Browser, mainly used for Functional and Regression Testing.It supports various Operating Environments. MS-Windows , Linux).It also supports various Browsers to create and execute Test Cases/Test Scripts(Mozilla Firefox, Google Chrome, Internet Explorer / MS Edge, Opera, Safari). Programming languages to write programs / Test Scripts supported by Selenium are Java , Python , C# .Net , Perl , Ruby , PHP.

Selenium environment Setup

Select Tools and Others:-

->Eclipse IDE for writing Test Scripts , Java for Programming , TestNG as Test Runner.

Steps:-

1.Download and Install Java Software (JDK) ->Create and execute programs/Test Scripts.

2.Set Environment Variable Path (Path variable) ->To use java from any Directory.

3.Download Eclipse IDE and Extract it ->To write and execute Java Programs.

4.Download Selenium WebDriver Java Language binding(from www.Seleniumhq.org) and extract it then add WebDriver jar files to Java Project in Eclipse IDE.

Download file->extract it->Launch Eclipse IDE ->Create Java Project->Select Project->Right Click ->Select Build Path->Select Configure Build Path ->Select Libraries Tab ->Click on Add External Jars ->Browse file which we download->Add file

5.Download Browser drivers (Set Browser driver path in Test Cases)

Download Third Party Browser Driver from www.Seleniumhq.org ->Select any Browser Driver ->Download it->Extract File->Save File in any Drive



6.Install TestNG

In Eclipse IDE->Help Menu ->Select “Install New S/w”->Click “Add”->Enter name as “TestNG”->Enter URL as “http://beust.com/eclipse/”->Click ->Then “TestNG” will be populated->Select “TestNG” ->Next->Next->Accept the agreement->Finish

Note:-

-> main method is not used in TestNG programs.

->TestNG Annotations are easy to create Test Cases.

->Test Cases can be grouped and prioritized more easily.

->Execute multiple programs/classes using xml.

->Generate Test Reports.

Write a Selenium Test Case using TestNG.

->Selenium Test Case to login Gmail:-

Test Steps:-

1.Launch Browser.

2.Maximize the Browser.

3.Navigate to Gmail(“https://www.google.co.in/”)

4.Click on Sign In Link.

// (With the help of element Locator id , we identifies a web Element(Sign In) within the web page.)

5.Enter Username.

//driver – Browser Object

 findElement – WebDriver Command to identify the element based on given locator.

 By – predefined class

 Id – locator

identifierId – locator value

sendKeys – WebDriver Command – To perform operation on the element.

abc@gmail.com – Input Data

6.Click on Next Button.

//className – locator

CwaK9 – locator value

click() – used to click an element (Button , Link , Radio Button , Check Box )

7.Enter Password.

//xpath -Locator -We can get xpath with the help of Firebug and Firepath

-Firebug and Firepath is a plug in which can download and add plug in only in  Mozilla Firefox Browser.

-Firebug (Add ons for Firefox->Add to Firefox->Install->Restart)

-Firepath(Add ons for Firefox->Add to Firefox->Install->Restart))

8.Click on Next Button

//className- locator

Example of Selenium Test Case to login Gmail in Eclipse:-

Advantages of Selenium

->It is an open source S/w.

->It supports various Operating Environments , Programming Platforms , Browser Environments, Parallel Testing.

->It uses less Hardware resources for Test Automation.

Disadvantages of Selenium

->It supports Web Application only.

->Less Support for Image-based Testing.

->No other Tool Integration for Test Management.

->No Built-in result Reporting Facility.


 

Leave a Reply

Your email address will not be published. Required fields are marked *