【发布时间】:2014-07-27 11:45:07
【问题描述】:
我是 selenium webdriver 的初学者,我正在尝试通过 xpath 登录 gmail 帐户,现在的问题是我找到了一个用于电子邮件的 xpath,并在其中发送了一个密钥。当我们运行报告发送到密码字段而不是电子邮件的密钥时,请帮助我如何解决它。 这是我的代码:
public class Usingxpath {
static boolean c,c1,c2;
public static void main(String[] args) throws Exception
{
// TODO Auto-generated method stub
WebDriver wD = new FirefoxDriver();
wD.get("https://www.gmail.com/");
Thread.sleep(2000);
c=wD.findElement(By.xpath("/html/body/div/div[2]/div[2]")).isDisplayed();
if(c==true){
System.out.println("SignIn board is present");
}
c1=wD.findElement(By.xpath("/html/body/div/div[2]/div[2]/form")).isDisplayed();
if(c1==true){
System.out.println("Form is present");
}
c2=wD.findElement(By.xpath("/html/body/div/div[2]/div[2]/form/input[15]")).isDisplayed();
if(c1==true){
System.out.println("email field is present");
}
WebElement emailInput= wD.findElement(By.xpath("/html/body/div/div[2]/div[2]/form/input[15]"));
emailInput.clear();
emailInput.sendKeys("xyz@gmail.com");
wD.quit();
}
【问题讨论】:
标签: email selenium xpath selenium-webdriver