Чтение данных из Excel в селене с получением «Ошибка при инициализации загрузочного слоя»: java .lang.module.ResolutionException: - PullRequest
0 голосов
/ 08 апреля 2020

Код:

package Selenium;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;

import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.util.NumberToTextConverter;

public class excelReader {

//Identify Testcases coloum by scanning the entire 1st row
//once coloumn is identified then scan entire testcase coloum to identify purcjhase testcase row
//after you grab purchase testcase row = pull all the data of that row and feed into test

public static ArrayList<String> getData(String testcaseName) throws IOException
{
//fileInputStream argument
ArrayList<String> a=new ArrayList<String>();

FileInputStream fis=new FileInputStream("C://Users//Sivaranjani Gopal//Desktop//siva.xlsx");
XSSFWorkbook workbook=new XSSFWorkbook(fis);

int sheets=workbook.getNumberOfSheets();
for(int i=0;i<sheets;i++)
{
if(workbook.getSheetName(i).equalsIgnoreCase("testdata"))
{
XSSFSheet sheet=workbook.getSheetAt(i);
//Identify Testcases coloum by scanning the entire 1st row

Iterator<Row> rows = sheet.iterator();

Row firstrow= rows.next();
Iterator<Cell> ce=firstrow.cellIterator();//row is collection of cells
int k=0;
int coloumn = 0;
while(ce.hasNext())
{
Cell value=ce.next();

if(value.getStringCellValue().equalsIgnoreCase("TestCases"))
{
coloumn=k;

}
k++;
}
System.out.println(coloumn);

////once coloumn is identified then scan entire testcase coloum to identify purcjhase testcase row
while(rows.hasNext())
{

Row r=rows.next();

if(r.getCell(coloumn).getStringCellValue().equalsIgnoreCase(testcaseName))
{

////after you grab purchase testcase row = pull all the data of that row and feed into test

Iterator<Cell>  cv=r.cellIterator();
while(cv.hasNext())
{
Cell c= cv.next();
if(c.getCellTypeEnum()==CellType.STRING)
{

a.add(c.getStringCellValue());
}
else{

a.add(NumberToTextConverter.toText(c.getNumericCellValue()));
}
}
}

}
}
}
return a;

}

public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub

    getData("siva");

}
}

Может ли кто-нибудь помочь с ошибкой:

При выполнении кода я получаю приведенное ниже исключение.

Ошибка при инициализации загрузочного слоя java .lang.module.ResolutionException: модули экспорта пакетов jaxb.impl и jaxb.core com.sun. xml .bind.v2.model.annotation для модуля poi

Нужна помощь по вышеуказанному исключению.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...