Showing posts with label automate gmail with selenium. Show all posts
Showing posts with label automate gmail with selenium. Show all posts

How to register in Facebook?


Below is the code to make an account on Facebook using Selenium Wedriver:

public class FacebookRegistration {

public static void main(String[]args)
{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.facebook.com/");
driver.manage().window().maximize();
driver.findElement(By.xpath("//*[@value='First Name']")).sendKeys("raj");
driver.findElement(By.xpath("//*[@value='Last Name']")).sendKeys("raja");
driver.findElement(By.xpath("//*[@value='Your email address']")).sendKeys("raja@mail.com");
driver.findElement(By.xpath("//*[@value='Re-enter email address']")).sendKeys("raja@mail.com");
driver.findElement(By.xpath("//*[@value='New Password']")).sendKeys("A123a!");
new Select(driver.findElement(By.xpath("//*[@name='birthday_day']"))).selectByValue("1");
new Select(driver.findElement(By.xpath("//*[@id='month']"))).selectByValue("2");
new Select(driver.findElement(By.xpath("//*[@id='year']"))).selectByValue("1987");
driver.findElement(By.xpath("//*[@id='u_0_g']/span[1]/label")).click();
driver.findElement(By.xpath("//*[@id='u_0_i']")).click();
}
}

How to Login and Logout in Gmail

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class Openbrowser
{
public static void main(String args[]) throws InterruptedException
{
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
driver.get("http://gmail.com/");
driver.findElement(By.id("Email")).sendKeys("raghav@mobikwik.com");
driver.findElement(By.id("Passwd")).sendKeys("9910979218");
driver.findElement(By.id("signIn")).click();
Thread.sleep(4000);
driver.findElement(By.xpath("//*[@id='gb']/div[1]/div[1]/div[2]/div[5]/div[1]/a/span")).click();
driver.findElement(By.id("gb_71")).click();
}
}