I am keeping my in file and the from there, because of avoid hard code..

Page

public void fielding(String field,String dist,String velo,String diff) {
  enterFielding.sendKeys(field);
  saveButton.click();
  textDistance.sendKeys(dist);
  dropDown.click();
  driver.findElement(By.name(velo)).click();
  textDifficulty.sendKeys(diff);
  buttonUpdate.click();
}

public void popOuttop2(String field,String dist,String velo,String diff) {
 //BH
 buttonB.click();
 buttonH.click();
 popOutButton.click();
 fielding(field,dist,velo,diff);
 buttonUpdate.click();
}

Steps

public class BaseBallEventSteps {

    WebDriver driver;
    BaseBallOutEvents baseOut;
    public BaseBallEventSteps() {
        baseOut = new BaseBallOutEvents(driver);
        baseOut=  PageFactory.initElements(DriverManager.driver, BaseBallOutEvents.class);
    }

    public void firstInningTopOut1(String field,String dist,String velo,String diff) throws InterruptedException 
    {
        baseOut.strikeOuttop1();
        baseOut.popOuttop2(field, dist, velo, diff);
        baseOut.strikeOutTop3();
    }
}

Main method

public static void main(String[] args) throws InterruptedException, IOException {


 DriverManager manager=new DriverManager();

 BaseBallEventSteps bs=new BaseBallEventSteps();

 File f= new File("Player_names.xlsx");
 FileInputStream fs= new FileInputStream(f);
 XSSFWorkbook wb= new XSSFWorkbook(fs); 
 XSSFSheet bb_players=  wb.getSheet("Sheet2");
 int rowcount= bb_players.getLastRowNum();

 String field =  bb_players.getRow(1).getCell(1).getStringCellValue();
 String dist= bb_players.getRow(1).getCell(2).getStringCellValue();
 String velo=bb_players.getRow(1).getCell(3).getStringCellValue();
 String diff=bb_players.getRow(1).getCell(4).getStringCellValue();

 bs.firstInningTopOut1(field,dist,velo,diff);
}

enter image description here

I want to know that I am doing correct or not ?
My data from excel is not reading in the main class…
Error :

Exception in thread "main" .lang.IllegalStateException: Cannot get a text value from a numeric cell

every time that i need to write the same String field = bb_players.getRow(1).getCell(1).toString(); to read the value from each cell.. but the length of the code should be more and is that every one following ?

Anybody please review my code , that i am doing correct or not, i can go further ?



Source link https://sqa.stackexchange.com/questions/34125/-to-read-data-from-excel-in---

LEAVE A REPLY

Please enter your comment!
Please enter your name here