【发布时间】:2016-08-24 08:42:50
【问题描述】:
在这里,我正在使用此代码进行阅读,并且我想在同一张纸上写出来.......我想根据将输出放在相关字段如何阅读和写现有的excel表? 1
如何使用 Selenium WebDriver 将数据写入 Excel 文件?
@Test(priority=1)
public void Shift() throws Exception {
String dupshiftname=Skadmin.getData(62, 1);
String validshiftname=Skadmin.getData(63, 1);
driver.findElement(By.linkText("ADMIN")).click();
driver.findElement(By.id("sessionname")).sendKeys(dupshiftname);
if (actualTitle19.contentEquals(expectedTitle19)){
System.out.println("2.Test Passed!-Submitting without shift name alert displayed as[Shift name is required]");
//这里我希望将上面的输出写在特定单元格的 excel 表上 }
public static String getData(int r, int c) throws EncryptedDocumentException, InvalidFormatException, IOException
{
FileInputStream FIS=new FileInputStream("G://workspace//sample pro//src//testData//excel.xlsx");
Workbook WB=WorkbookFactory.create(FIS);
DataFormatter formatter = new DataFormatter(); //creating formatter using the default locale
Cell cell = WB.getSheet("Sheet1").getRow(r).getCell(c);
String str = formatter.formatCellValue(cell); //Returns the formatted value of a cell as a String regardless of the cell type.
return str;
}
【问题讨论】:
标签: java selenium selenium-webdriver data-driven-tests