Selenium



WebDriver is an automation tool useful to perform Cross Browser Testing.
Verifying the AUT(application under test) against multiple browsers.
Limitation / Drawback –>WebDriver doesnt help us in automating Desktop based application. notepad.exe
Selenium WebDriver API (Application Programming Interface)
API Contains classes,methods,interfaces. All these are bundled and provided to us in jar file format.
A jar file named selenium-java.x.xx.zip downloaded added to the build path of the project.
Apart from that we have to add the jars available under lib directory also which are required for execution.
Selenium API- http://selenium.googlecode.com/git/docs/api/java/index.html.
Package ->org.openqa.selenium
Compatibility-> the selenium-java.x.xx.zip should be compatible with latest version of Chrome
Steps for configuration of eclipse with Selenium->

Configure Selenium WebDriver with Eclipse


TC_001:Verifying the title of page
1. Open Chrome Browser.
2. Enter the url http://total-qa.com/
3. Check the title
Expected Result:
“Selenium-Total-QA” is displayed
Actual Result:
“Selenium-Total-QA” is displayed
TestCase Result:
Pass
Identification of Objects/WebElements/HTML Components can be done in 8 ways: (or) Locators:
1. id
driver.findElement(By.id(“usernmae”))
2. name
driver.findElement(By.name(“username”));
driver.findElement(By.name(“password”));
3. className- -done
class=”textboxcolor” driver.findElement(By.className(“textboxcolor”));
class=”inputtext _58mg _5dba _2ph-”
//driver.findElement(By.className(“inputtext _58mg _5dba _2ph-“));
InvalidSelectorException:Compound class names not supported.
4. tagName
tagName=”input”
driver.findElement(By.tagName(“input”));//Select the username
5. linkText(hyperlink)-
WebElement e =driver.findElement(By.linkText(“Sign In”))
e.click();
6. partialLinkText(hyperlink) for dynamic links where the text is keep on changing. So we use the static part.
WebElement e =driver.findElement(By.linkText(“Sign”))
e.click();
WebElement e =driver.findElement(By.linkText(“In”))
e.click();
7. cssSelector
8. xpath – > xml path
Difference between close() and quit()
driver.close()-> closes the browser which has focus
driver.quit()->closes all the browser opened by Selenium WebDriver

Leave a Reply

Your email address will not be published. Required fields are marked *