I want to click on the 'compose' button in gmail inbox page.
My script is not able to although I have given a valid username and password.
WebDriver driver=new FirefoxDriver();
driver.get("https://accounts.google.com/ServiceLogin?service=mail&continue=https://mail.google.com/mail/#identifier");
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(500, TimeUnit.SECONDS);
driver.findElement(By.id("Email")).sendKeys("username");
driver.findElement(By.id("next")).click();
Thread.sleep(1000);
WebElement Err=driver.findElement(By.xpath("//*[@id='errormsg_0_Email']"));
String errtext=Err.getText();
if(!Err.isDisplayed()){
driver.findElement(By.id("Passwd")).sendKeys("password");
driver.findElement(By.id("signIn")).click();
Thread.sleep(1000);
List<WebElement> errorDivs = driver.findElements(By.xpath("//div[@class='error-msg']"));
if(errorDivs.isEmpty()){
driver.manage().timeouts().implicitlyWait(500, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id=':i7']/div/div")).click();
System.out.println("User loged in successfully");
}else{
errorDivs.get(0).getText();
driver.quit();
}
}else{
System.out.println("wrong password");
}
}
I am able to run your script after 2 changes: