Automation Using Selenium Webdriver

Monday 17 October 2016

Sing in-Sing out of Facebook using selenium WebDriver


Sign in- Sign out facebook Example using selenium webdriver
public class facebook
{
public static void main(String[] args) throws InterruptedException {

WebDriver driver = new HtmlUnitDriver();
driver.get("http://www.facebook.com");
System.out.println("Title of the page "+ driver.getTitle());
WebElement username = driver.findElement(By.id("email"));
username.sendKeys("xxxxx@gmail.com");
WebElement password = driver.findElement(By.id("pass"));
password.sendKeys("xxxxx");
WebElement Signup_button = driver.findElement(By.id("loginbutton"));
Signup_button.click();
Thread.sleep(5000);
System.out.println("After login title is = " + driver.getTitle());
WebElement logOut = driver.findElement(By.id("userNavigationLabel"));
logOut.click();
Thread.sleep(5000);
WebElement signOut = driver.findElement(By.name("Log Out"));
logOut.click();

System.out.println("Logged Out Successfully!!!!!!!!!!!!!!!!!!!");
String pagetitle = driver.getTitle();
System.out.println(pagetitle);

}}

No comments:

Post a Comment