Hi All,
If you are new to selenium webdriver and want to execute simple program then below i'm writing code for simple Gmail login.please see
//Name of the package
Package GmailLogin
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Gmail {
public static void main (String[] args)
{
try{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.gmail.com");
driver.manage().window().maximize();
WebDriverWait wait = new WebDriverWait(driver, 300);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='Email']")));
driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("Enter email id");
driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("Enter password");
driver.findElement(By.xpath(".//*[@id='signIn']")).click();
//Applying sleep in order to wait till Gmail mail page appears
Thread.sleep(19000);
driver.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Please execute above mentioned program, it will run perfectly.:)
If you are new to selenium webdriver and want to execute simple program then below i'm writing code for simple Gmail login.please see
//Name of the package
Package GmailLogin
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Gmail {
public static void main (String[] args)
{
try{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.gmail.com");
driver.manage().window().maximize();
WebDriverWait wait = new WebDriverWait(driver, 300);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='Email']")));
driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("Enter email id");
driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("Enter password");
driver.findElement(By.xpath(".//*[@id='signIn']")).click();
//Applying sleep in order to wait till Gmail mail page appears
Thread.sleep(19000);
driver.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
}
Please execute above mentioned program, it will run perfectly.:)
No comments:
Post a Comment