这是使用apache Poi的selenium代码,我正在从excel读取文件值并在excel文件中写入字符串值时打开一个链接,它给我零点异常。你能告诉我什么是错的吗?
在最后一行我收到错误,这些行是: -
sheet1.getRow(i).getCell(2).setCellValue(linkLocatin);
File src = new File ("C:\\Sandeep\\Selenium\\automationproject1\\Testdata.xlsx");
我的所有代码: -
FileInputStream fis = new FileInputStream(src);
XSSFWorkbook wb =new XSSFWorkbook (fis);
XSSFSheet sheet1 =wb.getSheetAt(0);
int rowcount= sheet1.getLastRowNum();
XSSFCell cel;
//System.out.println ("Test data is " + data0);
System.out.println ("rowncount is = "+ rowcount);
for (int i=1; i<= rowcount;i++)
{
//Set browser profile and then get link from excel
FirefoxProfile prof = new FirefoxProfile();
prof.setPreference("media.windows-media-foundation.enabled", false);
prof.setPreference("media.directshow.enabled", false);
prof.setAcceptUntrustedCertificates(true);
prof.setPreference("browser.download.dir","C:\\Sandeep\\Selenium\\automationproject1\\Download1");
prof.setPreference("browser.helperApps.alwaysAsk.force", false);
prof.setPreference("browser.helperApps.neverAsk.saveToDisk", "audio/x-mpeg-3");
prof.setPreference("browser.download.folderList", 2);
prof.setPreference("browser.download.manager.showWhenStarting",false);
WebDriver driver = new FirefoxDriver(prof);
String data0 = sheet1.getRow(i).getCell(1).getStringCellValue();
System.out.println(data0);
// open the link in browser
driver.get(data0);
WebElement link = driver.findElement(By.linkText("Download the recording"));
String linkLocatin = link.getAttribute("href");
sheet1.getRow(i).getCell(2).setCellValue(linkLocatin);
在excel中设置字符串值时,它显示空值异常..W