【发布时间】:2018-08-30 11:17:57
【问题描述】:
package Login;
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.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class Login
{
public static void main(String[] args) throws Exception
{
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Teknomines-5\\Downloads\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://www.google.com/intl/en-GB/gmail/about/");
//Thread.sleep(5000);
driver.findElement(By.xpath("/html/body/nav/div/a[2]")).click();
driver.findElement(By.xpath("//*[@id=\"identifierId\"]")).sendKeys("Pratik.modh24@gmail.com");
driver.findElement(By.xpath("//*[@id=\"identifierNext\"]")).click();
//Below Code password not print on PAssword textbox
//driver.findElement(By.xpath("/html/body/div[1]/div[1]/div[2]/div[2]/div/div/div[2]/div/div[1]/div/form/content/section/div/content/div[1]/div/div[1]")).sendKeys("123");
//driver.findElement(By.className("whsOnd zHQkBf")).sendKeys("123");
//driver.findElement(By.id("Passwd")).sendKeys("test123");
//driver.findElement(By.name("password")).sendKeys("123");
//driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("123456789");
//driver.findElement(By.cssSelector("#password > div:nth-child(1)")).sendKeys("123");
//driver.findElement(By.xpath("//INPUT[@name='password']")).sendKeys("******");
//driver.findElement(By.xpath("//INPUT[@type='password']/self::INPUT")).sendKeys("***");
//driver.findElement(By.xpath("(//DIV[@class='aCsJod oJeWuf'])[1]")).sendKeys("123456");
WebElement password = driver.findElement(By.xpath("//input[@name='password']"));
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(password));
password.sendKeys("your_password");
}
}
【问题讨论】:
标签: selenium selenium-webdriver xpath