Web driver
This is a functional testing component in selenium, which is used to
test web applciations
Using web driver we can test any no of pages, browsers in a single
o.s with latest version
Web driver supports programming languages like : java /
ruby/python/perl php and c#
Cross browser, parallel testing is possible by using TestNG or Junit
Framework design is possible by TestNG
The reports can be generated in the form of .xml file
Methods and locators in web driver are:
Methods( Operations)
Locators( properties of objects)
Methods in selenium web driver are:
1) Get(): to invoke or to call an application
Syntax:
Obj.get(url);
Example:
Obj.get(http://www.amazon.com);
2) Navigate().to(): to invoke or to call an applications
Syntax:
Obj.navigate().to(url);
Example:
Obj.navigate().to(“http://www.amazon.com”);
3) Maximizing: to max the current window
Syntax:
Obj.manage().window(),maximize();
4) Gettitle(): to get the current page title.
Syntax:
Obj.gettitle();
System.out.println(obj.gettitle());
Note:
To print a statement in java we use : system.out.println();
Or
String t1=obj.gettitle();
System.out.println(t1);
5) Getcurrenturl(); to get the current page url
Syntax:
Obj.getcurrenturl();
System.out.println(obj.getcurrenturl());
Or
String t2=obj.getcurrenturl();
System.out.println(t2);
6) Forward(): to move to next page window
Syntax:
Obj.navigate().forward();
7) Back(): to move to previous page
Syntax:
Obj.back();
8) Refresh(): to refresh the current page
syntax
obj.navigate().refresh();
9) findElement(): to capture a particular element from the
current window
syntax:
obj.findElement(By.locator(locatorvalue)).operations();
10) findElements: to capture multiple elements which are
related to a single functionality
examples: links , radio buttons, check boxes, dropdown
elements
syntax:
obj.findElements(By.locator(locatorvalues());
11) quit ():to close the current window
syntax:
obj.quit();
12) close(); to close all the window
syntax:
obj.close();
locators in web driver are:
id
name
classname
tagName
linkText
xpath
csslocator
man : object
name, color, height, address, contact no ,email id ,
Installation process:
Java / jre1.7 jdk 1.7 selenium-server-standalone-2.53.0 jar files/
eclipse
In eclipse :
Create project ------------------collection of packages (yahoo
page)
Create package ------------------collection of classes ( inbox )
Create class ====================single program
(checkbox)
Import a jar file into project ( selenium-server-standalone-2.53.o) jar
file
*.