Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SeleniumWebDriver和EclipseJava登录GMAIL的测试用例_Java_Eclipse_Selenium - Fatal编程技术网

SeleniumWebDriver和EclipseJava登录GMAIL的测试用例

SeleniumWebDriver和EclipseJava登录GMAIL的测试用例,java,eclipse,selenium,Java,Eclipse,Selenium,我需要在Eclipse中使用selenium验证gmail中的用户登录。 需要完成以下步骤。 1打开谷歌网站,搜索gmail,点击相应结果,进入网站,输入用户名和密码,点击登录,验证用户名。代码似乎是这样的,但我无法自动设置密码,它会在输入电子邮件时停止 'package gmailtest; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.Web

我需要在Eclipse中使用selenium验证gmail中的用户登录。 需要完成以下步骤。 1打开谷歌网站,搜索gmail,点击相应结果,进入网站,输入用户名和密码,点击登录,验证用户名。代码似乎是这样的,但我无法自动设置密码,它会在输入电子邮件时停止

 'package gmailtest;
 import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class firstgmail {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    System.setProperty( 
   "webdriver.gecko.driver","C:\\Desktop\\geckodriver-
    v0.16.1-win64\\geckodriver.exe");
    FirefoxDriver driver=new FirefoxDriver();
    driver.navigate().to("http://www.google.com.");

    WebDriverWait wait =new WebDriverWait(driver,10);
    String caseOfInputField = "input[name='q']";
    WebElement 

   inputFieldQ=wait.until(ExpectedConditions.elementToBeClickable
   (By.cssSelector(caseOfInputField)));
    inputFieldQ.sendKeys("GMAIL");
    //String caseOfSearchButton="button[name='btnG']";
    //WebElement searchButton 

   =wait.until(ExpectedConditions.elementToBeClickable(By.
    cssSelector(caseOfSearchButton)));
    //searchButton.click();

    driver.get("https://www.gmail.com/");
    driver.manage().window().maximize();
    driver.findElement(By.xpath(".//*[@id='identifierId']")).sendKeys("i@gmail.com");
    //driver.findElement(By.id("Email")).sendKeys("t@gmail.com");
    driver.findElement(By.xpath(".//*[@id='identifierNext']/content")).click();
    //driver.findElement(By.cssSelector("#next"));

    driver.findElement(By.xpath(".//*[@id='password']/div[1]/div/div[1]/input")).sendKeys("s@123");;


    //driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
    driver.findElement(By.id("signIn")).click();


    //driver.get("http://www.google.com.");
    //driver.findElement(By.xpath(""));




     //driver.quit();

}

}

从您的密码填充代码开始,尝试以下代码

  driver.findElement(By.xpath("//*[@name='password']")).click();
  Thread.sleep(1000);
  driver.findElement(By.xpath("//*[@name='password']")).clear();
  driver.findElement(By.xpath("//*[@name='password']")).sendkeys("yourpassword");

你能发布错误详细信息吗?谢谢您的Selenium版本和Mozilla Firefox版本是什么?Selenium 3.4和Mozilla Firefox版本48.0