从Excel检索数据时获得相同的价值

时间:2018-11-16 00:45:33

标签: selenium selenium-webdriver

在Excel工作表中有3列(电子邮件,名字,姓氏)attached screenshot。 我想在网页(attached screenshot)中传递值 当我传递值时,第一封电子邮件正在检索3个字段(电子邮件,名字,姓氏)。 下面提到的是编码

   WebElement email = driver.findElement(By.name("Email"));
    WebElement password = driver.findElement(By.name("Password"));
    WebElement confirmPassword = 
    driver.findElement(By.name("confirmPassword"));

    File file = new File("E:\\Selenium\\Selenium\\TestData.xlsx");
    FileInputStream inputStream = new FileInputStream(file);
    Workbook guruWorkbook = new XSSFWorkbook(inputStream);
    Sheet guruSheet = guruWorkbook.getSheet("TestData");

    int rowCount = guruSheet.getLastRowNum() - guruSheet.getFirstRowNum();

    for (int i = 1; i < rowCount + 1; i++) {

        Row row = guruSheet.getRow(i);

        for (int j = 0; j < row.getLastCellNum() - 1; j++) {
            /*
             * if(row.getCell(3).getStringCellValue().equals("Yes")) {
             * 
             * }
             */
            System.out.print(row.getCell(j).getStringCellValue() + "||");

            String emailText = row.getCell(j).getStringCellValue();
            String passText = row.getCell(j).getStringCellValue();
            String CpassText = row.getCell(j).getStringCellValue();


            System.out.println(emailText + " || " + passText + " || " + CpassText + " || ");

            email.sendKeys(emailText);
            password.sendKeys(passText);
            confirmPassword.sendKeys(CpassText);
            email.clear();
            password.clear();
            confirmPassword.clear();

        }

        System.out.println();
    }

请澄清。 在此先感谢

0 个答案:

没有答案