Professional Documents
Culture Documents
Selenium Notes
Selenium Notes
Selenium Notes
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(