Introduction to Selenium WebDriver
i) Introduction to Selenium WebDriver
ii) WebDriver Environment Setup
iii) Create outset Selenium Test Case
-------------------------------------------
i) Introduction to Selenium WebDriver
Selenium Tool’s Suite
Selenium IDE
Selenium RC
Selenium WebDriver
Selenium Grid
> In 2006 Selenium WebDriver was launched at Google.
> In 2008, the whole Selenium squad decided to merge Selenium WebDriver alongside Selenium RC inward fellowship to cast 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 entirely for maintenance projects.
----------------------
> It is a almost of import tool inward Selenium Suite.
> It has Programming interface only, no IDE.
> Selenium WebDriver supports diverse programming languages to write programs (Test scripts)
Java
Python
C#
Ruby
Perl
PHP
> 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 Windows
Linux
Macintosh etc...
> Selenium WebDriver supports Data driven Testing as well as Cross browser testing.
> Selenium WebDriver is faster than other tools of Selenium suite.
> Selenium WebDriver supports Parallel examination execution alongside the aid of either JUnit or TestNG.
-------------------------------
Drawbacks of selenium Webdriver
> Selenium WebDriver doesn't convey IDE (some hard to practise examination cases)
> No Built-in Result reporting facility.
> No other tool Integration for Test management.
> No centralized maintenance of Elements/objects.
--------------------------------------------------
How nosotros practise Test Cases /Test Scripts / Tests inward Selenium WebDriver:
In UFT:
Using Objects information as well as Test Methods nosotros practise Tests.
In Selenium WebDriver:
Using Element Locators as well as Webdriver Commands/methods nosotros practise Test Cases.
Selenium IDE:
Using Element locators as well as Selenese / Selenium IDE commands nosotros practise Test cases
-----------------------------------
Element Locators - to recognize elements/identify elements.
WebDriver commands/methods - to perform operations on elements.
--------------------------------------
Java Programming - for enhancing Test Cases
TestNG Framework - for grouping Test cases, batch Testing as well as generating Test Reports.
-----------------------------------------------------------
ii) Selenium WebDriver Environment Setup.
Steps:
1) Download as well as Install Java (JDK) software -to practise programs (Test scripts)
2) Set Environment variable (path variable).
3) Download Eclipse IDE as well as extract - to write as well as execute Java programs.
4) Download Webdriver Java linguistic communication binding (www.seleniumhq.org) as well as add together WebDriver jolt files to Java projection inward Eclipse IDE.
---------------------------------------
5) Install Firebug as well as Firepath plug ins (Mozilla Firefox) for inspecting elements.
6) For Internet Explorer as well as Google Chrome, no bespeak to install whatever plug in, they have
built inward developer tools(F12) for inspecting elements.
7) Firefox driver is default driver inward Seelenium Webdriver, for IE as well as Chrome etc... Browsers as well as thence nosotros bespeak to download browser drivers.
--------------------------------------------
Download Selenium WebDriver Java linguistic communication binding from www.seleniumhq.org website as well as extract.
Add WebDriver jolt files to Java Project inward Eclipse IDE
Navigation:
Create Java Project
> Select Java projection as well as correct click
> Build path
> Configure ready path
> Select "Libraries" tab
> Click "Add external Jars"
> Browse path of the WebDriver jars.
> Add
-----------------------------------------
Create Selenium WebDriver Test Case
> Import Webdriver as well as Firefox/IE/Chrome Libraries. (In Selenium Test Case/Program)
> Using Element locators as well as Webdriver commands write examination steps.
> Insert coffee programming statements to get upwards Test cases.
-----------
> Using TestNG Annotations grouping examination cases, execute examination batches as well as generate detailed examination reports.
--------------------------------------------------
iii) Write outset Selenium Test Case
Manual Test Case
Test Case ID: gcrshop_admin_TC001
Test Case Name: Verify Admin Login inward GCR store Web Portal
Test Steps:
1) Launch the Browser as well as navigate to "www.gcrit.com/build3/admin"
2) Enter User name
3) Enter Password
4) Click Login Button
Input data:
Username = admin
Password =admin@123
Expected URL: "www.gcrit.com/build3/admin/index.php"
Actual: http://www.gcrit.com/build3/admin/index.php
Test Result: Pass
-------------------------------------------
* Verification point: Capture the Browser URL subsequently submission of Login details as well as compare alongside expected URL.
----------------------------------------------------------------
Selenium WebDriver Test Case:
public cast AdminLogin {
public static void main(String[] args) {
WebDriver driver = novel FirefoxDriver(); //Launches Firefox Browser alongside blank url
driver.get("http://www.gcrit.com/build3/admin/login.php");
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 the Browser
}
}
----------------------------------------------------
i) Introduction to Selenium WebDriver
ii) WebDriver Environment Setup
iii) Create outset Selenium Test Case
-------------------------------------------
i) Introduction to Selenium WebDriver
Selenium Tool’s Suite
Selenium IDE
Selenium RC
Selenium WebDriver
Selenium Grid
> In 2006 Selenium WebDriver was launched at Google.
> In 2008, the whole Selenium squad decided to merge Selenium WebDriver alongside Selenium RC inward fellowship to cast 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 entirely for maintenance projects.
----------------------
> It is a almost of import tool inward Selenium Suite.
> It has Programming interface only, no IDE.
> Selenium WebDriver supports diverse programming languages to write programs (Test scripts)
Java
Python
C#
Ruby
Perl
PHP
> 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 Windows
Linux
Macintosh etc...
> Selenium WebDriver supports Data driven Testing as well as Cross browser testing.
> Selenium WebDriver is faster than other tools of Selenium suite.
> Selenium WebDriver supports Parallel examination execution alongside the aid of either JUnit or TestNG.
-------------------------------
Drawbacks of selenium Webdriver
> Selenium WebDriver doesn't convey IDE (some hard to practise examination cases)
> No Built-in Result reporting facility.
> No other tool Integration for Test management.
> No centralized maintenance of Elements/objects.
--------------------------------------------------
How nosotros practise Test Cases /Test Scripts / Tests inward Selenium WebDriver:
In UFT:
Using Objects information as well as Test Methods nosotros practise Tests.
In Selenium WebDriver:
Using Element Locators as well as Webdriver Commands/methods nosotros practise Test Cases.
Selenium IDE:
Using Element locators as well as Selenese / Selenium IDE commands nosotros practise Test cases
-----------------------------------
Element Locators - to recognize elements/identify elements.
WebDriver commands/methods - to perform operations on elements.
--------------------------------------
Java Programming - for enhancing Test Cases
TestNG Framework - for grouping Test cases, batch Testing as well as generating Test Reports.
-----------------------------------------------------------
ii) Selenium WebDriver Environment Setup.
Steps:
1) Download as well as Install Java (JDK) software -to practise programs (Test scripts)
2) Set Environment variable (path variable).
3) Download Eclipse IDE as well as extract - to write as well as execute Java programs.
4) Download Webdriver Java linguistic communication binding (www.seleniumhq.org) as well as add together WebDriver jolt files to Java projection inward Eclipse IDE.
---------------------------------------
5) Install Firebug as well as Firepath plug ins (Mozilla Firefox) for inspecting elements.
6) For Internet Explorer as well as Google Chrome, no bespeak to install whatever plug in, they have
built inward developer tools(F12) for inspecting elements.
7) Firefox driver is default driver inward Seelenium Webdriver, for IE as well as Chrome etc... Browsers as well as thence nosotros bespeak to download browser drivers.
--------------------------------------------
Download Selenium WebDriver Java linguistic communication binding from www.seleniumhq.org website as well as extract.
Add WebDriver jolt files to Java Project inward Eclipse IDE
Navigation:
Create Java Project
> Select Java projection as well as correct click
> Build path
> Configure ready path
> Select "Libraries" tab
> Click "Add external Jars"
> Browse path of the WebDriver jars.
> Add
-----------------------------------------
Create Selenium WebDriver Test Case
> Import Webdriver as well as Firefox/IE/Chrome Libraries. (In Selenium Test Case/Program)
> Using Element locators as well as Webdriver commands write examination steps.
> Insert coffee programming statements to get upwards Test cases.
-----------
> Using TestNG Annotations grouping examination cases, execute examination batches as well as generate detailed examination reports.
--------------------------------------------------
iii) Write outset Selenium Test Case
Manual Test Case
Test Case ID: gcrshop_admin_TC001
Test Case Name: Verify Admin Login inward GCR store Web Portal
Test Steps:
1) Launch the Browser as well as navigate to "www.gcrit.com/build3/admin"
2) Enter User name
3) Enter Password
4) Click Login Button
Input data:
Username = admin
Password =admin@123
Expected URL: "www.gcrit.com/build3/admin/index.php"
Actual: http://www.gcrit.com/build3/admin/index.php
Test Result: Pass
-------------------------------------------
* Verification point: Capture the Browser URL subsequently submission of Login details as well as compare alongside expected URL.
----------------------------------------------------------------
Selenium WebDriver Test Case:
public cast AdminLogin {
public static void main(String[] args) {
WebDriver driver = novel FirefoxDriver(); //Launches Firefox Browser alongside blank url
driver.get("http://www.gcrit.com/build3/admin/login.php");
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 the Browser
}
}
----------------------------------------------------