Selenium WebDriver Tutorial for Beginners
i) Introduction to Selenium WebDriver
ii) Selenium WebDriver Environment Setup
iii) Write starting fourth dimension Selenium Test Case
---------------------------------------------------
i) Introduction to Selenium WebDriver
Selenium's Tool Suite
Selenium IDE
Selenium RC
Selenium WebDriver
Selenium Grid
--------------------------------------
Selenium WebDriver:
> In 2006, Selenium WebDriver was launched at Google.
> In 2008, the whole Selenium squad decided to merge Selenium RC amongst Selenium WebDriver inwards gild to shape to a greater extent than powerful tool called Selenium 2.0
Selenium 1.0 + 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 alone for maintenance Projects.
----------------------------------------
Selenium WebDriver Features:
> It has Programming Interface only, no IDE
----------------------------------------
Selenium IDE :
We tin flaming practise Test cases using Recording characteristic as well as heighten Test cases using Selenese Commands/ Selenium IDE Commands.
Using Element Locators as well as Selenese Commands nosotros practise Test cases inwards Selenium IDE.
No Programming inwards Selenium IDE.
Selenium WebDriver:
We practise Test Cases using Element Locators as well as WebDriver Methods/Commands, Enhance Test cases using programming features.
No IDE inwards Selenium WebDriver.
UFT/QTP:
We practise Tests using Tool features (Ex: Recording etc...)and heighten Tests using Tool features (Ex: Checkpoints, Output values, Data Table etc...) as well as Script/Programming features (Ex: Conditional Statements, Loop Statements, Functions etc...).
IDE every bit good every bit Programming Interface.
---------------------------------------------
Test Design
Generate Basic Tests/Test Cases
Enhance Tests
----------------------------------------------
General
Object Property Value Operations
Dog name abcd Run, Jump etc...
height 40 Cm
color black
weight etc... 10 Kg
Man name
surname
color
weight
Age etc...
--------------------------------------------------------------
UFT
Object Property Value Operations
Link text Gmail Click, depository fiscal establishment jibe enabled condition etc...
height
enabled true
visible true
x
y
Selenium
Element Locator Value Operations
Edit box id Email Enter a Value, Check enabled status
name
xpath
-------------------------------------------------------------------------------------
> Selenium WebDriver supports diverse programming languages to write Test scripts.
Java
C#
Python
PHP
Ruby
Perl
> Selenium WebDriver supports diverse Browsers to practise as well as execute Test Cases
Mozilla Firefox
Google Chrome
IE
Safari
Opera etc...
> Selenium WebDriver supports diverse operating environments
MS Window
Linux
Macintosh etc...
> Selenium WebDriver supports Data Driven Testing as well as Cross Browser Testing.
> Selenium WebDriver is faster inwards exam execution when it compares to other Functional Test tools.
> Selenium supports parallel exam execution.
> Selenium WebDriver supports Batch Testing amongst the attention of either JUnit or TestNG Framework.
----------------------------------------------
Drawbacks of Selenium WebDriver:
> Selenium WebDriver doesn't guide maintain IDE (No Tool features), as well as thence creating exam cases takes to a greater extent than fourth dimension as well as efforts.
> Selenium WebDriver supports alone Web Applications (doesn't back upwardly Desktop Applications)
> No built inwards Result Reporting facility
> No reliable Technical support
> Limited back upwardly for Image Testing
> No other tool integration for Test Management.
---------------------------------------------------
ii) Selenium WebDriver Environment Setup
Steps:
1) Download as well as Install Java (jdk) software - To practise as well as execute programs (Test Scripts)
2) Set Environment variable (Path Variable) - Optional (only for Command line)
3) Download Eclipse IDE as well as Extract. - To write as well as execute Java programs.
--------------------------------------------------------
4) Download Selenium WebDriver Java Language binding from www.seleniumhq.org as well as Add WebDriver
jar files to Java Project inwards Eclipse IDE.
----------------------------------------
ii) Selenium WebDriver Environment Setup:
Download Selenium WebDriver Java Language binding as well as extract.
Add Selenium WebDriver Java langauge binding to Java Project inwards Eclipse
Navigation:
> Create Java Project
> Select Java Project as well as Right click
> Build path
> Configure Bulid path
> Select Libraries Tab
> Click "External Jars"
> Browse path of Selenium WebDriver jars
> Add
---------------------------------------------------
iii) Create Selenium WebDriver Test Case:
Manual Test Case:
a) Test Case ID: gcrShop_admin_TC001
b) Test Case Name: Verify Admin Login inwards GCR Shop spider web portal.
c) Test Steps:
1) Launch the Browser as well as Navigate to "http://www.gcrit.com/build3/admin/"
2) Enter Username
3) Enter Password
4) Click "Login" Button
-----------------------
d) Verification Point/s
Capture URL afterwards Login as well as compare amongst expected.
Expected: http://www.gcrit.com/build3/admin/index.php
Actual: http://www.gcrit.com/build3/admin/index.php
e) Input Data / Test Data
Username = "admin"
Password = "admin@123"
f) Result: Pass
--------------------------------------------
Inspect Elements
Mozilla Firefox - Page Inspector (Built inwards Feature) to inspect Elements/ Download as well as Install Firebug Plug in
Google Chrome - Developer Tools (Built in) / F12
IE - Developer Tools (Built-in) / F12
-------------------------------------------------------
Selenium WebDriver Test Case:
public static void main(String[] args) {
WebDriver driver= novel FirefoxDriver();//Launches Firefox browser amongst blank url
driver.get("http://www.gcrit.com/build3/admin/"); //Navigates to Admin Home page
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("Login Successful - Passed");
}
else {
System.out.println("Login Unsuccessful - Failed");
}
driver.close();//Closes Browser
}
}
-----------------------------------------------------
i) Introduction to Selenium WebDriver
ii) Selenium WebDriver Environment Setup
iii) Write starting fourth dimension Selenium Test Case
---------------------------------------------------
i) Introduction to Selenium WebDriver
Selenium's Tool Suite
Selenium IDE
Selenium RC
Selenium WebDriver
Selenium Grid
--------------------------------------
Selenium WebDriver:
> In 2006, Selenium WebDriver was launched at Google.
> In 2008, the whole Selenium squad decided to merge Selenium RC amongst Selenium WebDriver inwards gild to shape to a greater extent than powerful tool called Selenium 2.0
Selenium 1.0 + 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 alone for maintenance Projects.
----------------------------------------
Selenium WebDriver Features:
> It has Programming Interface only, no IDE
----------------------------------------
Selenium IDE :
We tin flaming practise Test cases using Recording characteristic as well as heighten Test cases using Selenese Commands/ Selenium IDE Commands.
Using Element Locators as well as Selenese Commands nosotros practise Test cases inwards Selenium IDE.
No Programming inwards Selenium IDE.
Selenium WebDriver:
We practise Test Cases using Element Locators as well as WebDriver Methods/Commands, Enhance Test cases using programming features.
No IDE inwards Selenium WebDriver.
UFT/QTP:
We practise Tests using Tool features (Ex: Recording etc...)and heighten Tests using Tool features (Ex: Checkpoints, Output values, Data Table etc...) as well as Script/Programming features (Ex: Conditional Statements, Loop Statements, Functions etc...).
IDE every bit good every bit Programming Interface.
---------------------------------------------
Test Design
Generate Basic Tests/Test Cases
Enhance Tests
----------------------------------------------
General
Object Property Value Operations
Dog name abcd Run, Jump etc...
height 40 Cm
color black
weight etc... 10 Kg
Man name
surname
color
weight
Age etc...
--------------------------------------------------------------
UFT
Object Property Value Operations
Link text Gmail Click, depository fiscal establishment jibe enabled condition etc...
height
enabled true
visible true
x
y
Selenium
Element Locator Value Operations
Edit box id Email Enter a Value, Check enabled status
name
xpath
-------------------------------------------------------------------------------------
> Selenium WebDriver supports diverse programming languages to write Test scripts.
Java
C#
Python
PHP
Ruby
Perl
> Selenium WebDriver supports diverse Browsers to practise as well as execute Test Cases
Mozilla Firefox
Google Chrome
IE
Safari
Opera etc...
> Selenium WebDriver supports diverse operating environments
MS Window
Linux
Macintosh etc...
> Selenium WebDriver supports Data Driven Testing as well as Cross Browser Testing.
> Selenium WebDriver is faster inwards exam execution when it compares to other Functional Test tools.
> Selenium supports parallel exam execution.
> Selenium WebDriver supports Batch Testing amongst the attention of either JUnit or TestNG Framework.
----------------------------------------------
Drawbacks of Selenium WebDriver:
> Selenium WebDriver doesn't guide maintain IDE (No Tool features), as well as thence creating exam cases takes to a greater extent than fourth dimension as well as efforts.
> Selenium WebDriver supports alone Web Applications (doesn't back upwardly Desktop Applications)
> No built inwards Result Reporting facility
> No reliable Technical support
> Limited back upwardly for Image Testing
> No other tool integration for Test Management.
---------------------------------------------------
ii) Selenium WebDriver Environment Setup
Steps:
1) Download as well as Install Java (jdk) software - To practise as well as execute programs (Test Scripts)
2) Set Environment variable (Path Variable) - Optional (only for Command line)
3) Download Eclipse IDE as well as Extract. - To write as well as execute Java programs.
--------------------------------------------------------
4) Download Selenium WebDriver Java Language binding from www.seleniumhq.org as well as Add WebDriver
jar files to Java Project inwards Eclipse IDE.
----------------------------------------
ii) Selenium WebDriver Environment Setup:
Download Selenium WebDriver Java Language binding as well as extract.
Add Selenium WebDriver Java langauge binding to Java Project inwards Eclipse
Navigation:
> Create Java Project
> Select Java Project as well as Right click
> Build path
> Configure Bulid path
> Select Libraries Tab
> Click "External Jars"
> Browse path of Selenium WebDriver jars
> Add
---------------------------------------------------
iii) Create Selenium WebDriver Test Case:
Manual Test Case:
a) Test Case ID: gcrShop_admin_TC001
b) Test Case Name: Verify Admin Login inwards GCR Shop spider web portal.
c) Test Steps:
1) Launch the Browser as well as Navigate to "http://www.gcrit.com/build3/admin/"
2) Enter Username
3) Enter Password
4) Click "Login" Button
-----------------------
d) Verification Point/s
Capture URL afterwards Login as well as compare amongst expected.
Expected: http://www.gcrit.com/build3/admin/index.php
Actual: http://www.gcrit.com/build3/admin/index.php
e) Input Data / Test Data
Username = "admin"
Password = "admin@123"
f) Result: Pass
--------------------------------------------
Inspect Elements
Mozilla Firefox - Page Inspector (Built inwards Feature) to inspect Elements/ Download as well as Install Firebug Plug in
Google Chrome - Developer Tools (Built in) / F12
IE - Developer Tools (Built-in) / F12
-------------------------------------------------------
Selenium WebDriver Test Case:
public static void main(String[] args) {
WebDriver driver= novel FirefoxDriver();//Launches Firefox browser amongst blank url
driver.get("http://www.gcrit.com/build3/admin/"); //Navigates to Admin Home page
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("Login Successful - Passed");
}
else {
System.out.println("Login Unsuccessful - Failed");
}
driver.close();//Closes Browser
}
}
-----------------------------------------------------