Saturday, April 2, 2022

Selenium - Facebook Create New Account

 package selenium;
import java.time.Duration;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.Select;
public class Fb_Create_New_Account {
 public static void main(String[] args) throws InterruptedException {
      System.setProperty("webdriver.chrome.driver","C:\\Selenium\\chromedriver\\chromedriver.exe");
      WebDriver driver = new ChromeDriver();
      driver.manage().window().maximize();
      driver.get( "https://en-gb.facebook.com/");
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(20));
driver.findElement(By.linkText("Create New Account")).click();
driver.findElement(By.name("firstname")).sendKeys("Suriya");
driver.findElement(By.name("lastname")).sendKeys("Parithy");
driver.findElement(By.name("reg_email__")).sendKeys("8012345679");
        driver.findElement(By.name("reg_passwd__")).sendKeys("123098");
        
      //Static dropdown
        Select date = new Select(driver.findElement(By.id("day")));
        Thread.sleep(1000);
        date.selectByVisibleText("1");
        Select month = new Select(driver.findElement(By.id("month")));
        Thread.sleep(1000);
        month.selectByValue("4");
        Select year = new Select(driver.findElement(By.id("year")));
        Thread.sleep(1000);
        year.selectByValue("1996");
        
      //Radio button
        driver.findElement(By.xpath("//input[@value='2']")).click(); //for selecting male
        driver.findElement(By.name("websubmit")).click();
        driver.close();
 }
}

No comments:

Post a Comment