Selenium Notes

You might also like

Download as rtf, pdf, or txt
Download as rtf, pdf, or txt
You are on page 1of 3

Selenium Tutorial

--------------------------------------------------------------------------------------------------------------Create Test Cases/ test cases using selenium webdriver


--------------------------------------------------------------------------------------------------------------1. Selenium Web driver setup
2.Element Locators
3.WebDriver Methods
4.Create Tests using Element locators and WebDriver methods
5.Cross Browser ()
----------------------------------------------------------------------------------------------------------------Requirments :
OS : WIN 7/8
Programming Lang : Java
IDE : Eclipse
-----------------------------------------------------------------------------------------------------------------Download java (JDK) and Install
Set path variables (Environmental variables )inorder to access java from all
directories
Download Eclipse
Download Webdriver java Language binding and add to eclipse(add External
Jars
Download and Install Firebug and firepath Add on for Firefox to inspect web
elements

Note : no need to install for Chrome and IE its bult in developer tools can be
usedF12
---------------------------------------------------------------------------------------------------------------Two things are important in creating tests/test cases/test scripts in selenium.
1.Element locators to identify web elements
2.Webd0river methods to perform operations on Web elements
3.Programming features like loops,conditional
statements,Methods,variables,operators to enhance test cases.
-----------------------------------------------------------------------------------------------------------------Web Element locators:
Selenium WebDriver uses 8 element locators to find elements on Web Pages.
Why we need to use different locators?
Developers may not provide all element locators
Some locators may be duplcate
so we have to choose any one unique locator to recognize the element.
-----------------------------------------------------------------------------------------------------------------1.ID
Syntax :
driver.findElement(By.id("Email")).submit();

2.Name :
driver.findElement(By.name("Email")).sendKeys("aravind");
or
Webelement E = driver.findelement(By.name("Email"));
E.click();
3.ClassName:

driver.findElement(By.className("Email")).sendKeys("aravind");
4.Tag name
driver.findElement(By.tagName("input")).sendKeys("aravind");
driver.get("file:///E:loginpage.html");
5.Linktext
driver.findElement(By.linkText("Gmail")).click();
6.PartialLinktext
driver.findElement(By.partialLinkText("Gma"));
7.Css Selector
driver.findElement(By.cssSelector(".signup-link"));
8.Xpath
driver.findElement(By.xpath(".//*[@id='signIn']")).submit();

----------------------------------------------------------------------------------

WebDriver Methods
Get Method(
It opens specified url in the browser window
example:
driver.get("http://www.google.com");
getTitle Method()
example:
string Title = driver.getTitle(

You might also like