0

I am using SeleniumWebDriver using Java to automation one of the portal applications. As part of this, I want to read username and password from Excel and written below code. But seeing Exception in thread "main" java.lang.NoClassDefFoundError: org/openxmlformats/schemas/drawingml/x2006/main/ThemeDocument Below is the code

import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.Random;

    public class BankingFaceLift {
        static WebDriver  driver = null;


        public static void main(String[]args){

            driver = new FirefoxDriver();
            driver.get("https://obsit.enbduat.com/obweb/common/login.jsf?faces-redirect=true");
            driver.manage().window().maximize();
            driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

            try
            {    
                File file = new File("TestData.xlsx");
                FileInputStream iFile = new FileInputStream(file);

                XSSFWorkbook wb = new XSSFWorkbook(iFile);
                XSSFSheet sheet = wb.getSheet("Sheet1");

                int rowCount = sheet.getLastRowNum();
                System.out.println("the no of rows are : " + rowCount);
                for (int row=1; row<=rowCount; row++)
                {

                    String Username = sheet.getRow(row).getCell(0).getStringCellValue();
                    String Password = sheet.getRow(row).getCell(1).getStringCellValue();
                    driver.findElement(By.id("username")).sendKeys(Username);
                    driver.findElement(By.id("j_idt49")).sendKeys(Password);
                    driver.findElement(By.id("submit")).click();

I have imported poi-xxx.jar and poi-ooxml.jar1.

Kindly advice Thanks!

6
  • Please share the complete exception Commented Sep 6, 2016 at 11:54
  • Please find complete exception ` Exception in thread "main" java.lang.NoClassDefFoundError: org/openxmlformats/schemas/drawingml/x2006/main/ThemeDocument at java.lang.Class.getDeclaredConstructors0(Native Method) at java.lang.Class.privateGetDeclaredConstructors(Unknown Source) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getDeclaredConstructor(Unknown Source) at org.apache.poi.xssf.usermodel.XSSFFactory.createDocumentPart(XSSFFactory.java:59) at org.apache.poi.POIXMLDocumentPart.read(POIXMLDocumentPart.java:465)` Commented Sep 6, 2016 at 12:05
  • problem in some where, either your project / package Commented Sep 6, 2016 at 12:28
  • @ prabu.. can you please be specific when you say problem with project / package ? I didn't get it. Can you please point where could be the issue Commented Sep 6, 2016 at 12:39
  • i think this exception in not related to poi,not an issue in the reading excel part Commented Sep 6, 2016 at 12:44

1 Answer 1

2

You need to import poi-ooxml-schemas jar as well. You can download the jar from here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.