Selenium WebDriver Introduction

Introduction to Selenium WebDriver

i) Introduction to Selenium WebDriver

ii) Selenium WebDriver Environment Setup

iii) Write first Selenium Test Case
----------------------------------------------
i) Introduction to Selenium WebDriver

Selenium's Tool Suite
   
    Selenium IDE
    Selenium RC
    Selenium WebDriver
    Selenium Grid
----------------------------------------------
Selenium WebDriver Features:

> In 2006, Selenium WebDriver was launched at Google.

> In 2008, the whole Selenium team decided to merge Selenium RC with Selenium WebDriver
in order to form more powerful tool called Selenium 2.0

Selenium 1.0 + Selenium WebDriver = Selenium 2.0

Selenium 1.0

Selenium IDE + Selenium RC + Selenium Grid

Selenium 2.0

Selenium IDE + Selenium RC + Selenium WebDriver + Selenium Grid

Note: Now Selenium RC is only for maintenance Projects
----------------------------------------------
Selenium WebDriver Features:

> Selenium WebDriver doesn't have IDE (Integrated Development Environment), only Programming Interface

> Using Element Locators and WebDriver Commands we create Test Cases

Element / Object    Locator / Property    Value
--------------------------------------------------------
Dog                       color                      black
                            height                    30
--------------------------------------------------------
Edit box                  name                    Email

link                         linkText                Gmail
----------------------------------------------------------
> Selenium WebDriver supports various Operating Environments

MS Windows
Linux
Macintosh etc...

> Selenium WebDriver supports various Programming Environments to write Test Scripts/Programs.

Java
C#
Perl
Python
Ruby
PHP

> Selenium WebDriver supports various Browsers

Mozilla Firefox

Google Chrome

IE

Safari

Opera etc...

> Selenium WebDriver supports various Testing Frameworks,

JNunit
TestNG
-----------------
NUnit

> It supports Batch Testing, Data Driven Testing, Database Testing and Parallel Test execution
----------------------------------------------
Drawbacks of Selenium WebDriver
> Selenium WebDriver supports only Web Applications

> It doesn't have IDE, so creating Test Cases takes more time and efforts.

> No reliable Technical support.

> No built in Result Reporting facility.

> Limited support for Image Testing

> No other tool integration with Selenium WebDriver for Test Management
----------------------------------------------
ii) Selenium WebDriver Environment Setup

Steps:

1) Download and Install Java Software (jdk) - To create and execute programs (Test Scripts)

2) Download Eclipse IDE and Extract - Platform to write and execute Java Programs.

3) Download Selenium WebDriver Java Language binding from www.seleniumhq.org and Add  WebDriver jar files to Java Project in Eclipse IDE.
---------------------------------------------------------
Download Browser drivers (Chrome, IE, safari etc...) to execute Test Cases using different browsers.
--------------------------------------------------------
You can download and Install Firebug and Firepath plug ins for Firefox Browser to inspect elements,

Or
You can use Firefox Browser built in feature "Page Inspector" to inspect elements

If we use Chrome or IE, they have built-in developer tools to inspect elements.
----------------------------------------------
WebDriver Environment Setup:

> Create Java Project
>Select Java Project in Eclipse IDE and right click
> Build path
> Configure build path
> Select Libraries tab
> Click "External jars"
> Browse path of selenium Webdriver jars
> Add
----------------------------------------------
iii) Write first Selenium Test Case

Test Scenario / Manual Test Case

Test Case Name: Verify Admin Login in gcrShop web portal

Test Steps:
1) Launch the Browser
2) Navigate to "http://www.gcrit.com/build3/admin/"
3) Enter Username
4) Enter Password
5) Click "Login" Button

Test Data:

Username = admin
Password = admin@123

Verification Point:
 

Capture the URL after Login and compare with expected.

Expected: http://www.gcrit.com/build3/admin/index.php

Actual:

Status: Pass/Fail
----------------------------------------------
Inspect Elements:
Username -Edit box- username (name locator value) - madhuri@gmail.com (Input data/Test Data)
 

Password -Edit box - password (name locator value) -
 

Login - Button - tdb1 (id locator value)
---------------------------
Element Locators - To identify/recognize/locate Elements
 

WebDriver Commands - To perform Operations on Elements
----------------------------------------------
Write Selenium WebDriver Test Case:

WebDriver driver = new FirefoxDriver();
driver.get("http://www.gcrit.com/build3/admin/");
driver.findElement(By.name("username")).sendKeys("admin");
driver.findElement(By.name("password")).sendKeys("admin@123");
driver.findElement(By.id("tdb1")).click();

String url = driver.getCurrentUrl();

if (url.equals("http://www.gcrit.com/build3/admin/index.php")){
System.out.println("Admin Login Successful - Passed");
}
else {
System.out.println("Admin Login Unsuccessful - Failed");
}
driver.close();
}
}
----------------------------------------------
String url = driver.getCurrentUrl();
if (url.equals("http://www.gcrit.com/build3/admin/index.php")){
}

Or

if ((driver.getCurrentUrl()).equals("http://www.gcrit.com/build3/admin/index.php")){
}
----------------------------------------------
Keywords used in this Test Case:
driver / driver Object - Firefox Browser Driver

get - WebDriver Command
findElement - WebDriver Command
sendKeys -WebDriver Command
click - WebDriver Command
getCurrentUrl -WebDriver Command
close - WebDriver Command

By - Predifined Class

name - Element Locator
id - Element Locator

username - Element Locator Value
password- Element Locator Value
tdb1- Element Locator Value

admin - Input / Test Data
admin@123 - Input / Test Data

if - Java Conditional Statement

equals - Java String Method
----------------------------------------------

0 comments:

Post a Comment