0

I am using below mentioned selenium code to fetch data from excel and type that in textbox of website. It is fetching and storing data correctly in object array but it is giving me error while writing that data in excel i.e last line of the code is not working. Can anyone help me that how can i pass value of obj[0][2] into textbox ?

XLSDatatable_Connectivity data= new XLSDatatable_Connectivity (System.getProperty("user.dir") +"\\src\\Excel\\CreateUser.xlsx");    
int rows= data.totalRow("CreateUser");
int column= data.totalColumn("CreateUser");


Object obj[][]=new Object[rows-1][column];

for(int row=2; row<=rows;row++)
{
    for(int col=0;col<column;col++)
    {
    obj[row-2][col]= data.getData("CreateUser", col, row);
    }
}

driver.findElement(By.xpath("//*[@id='oUsersInfo_Name']")).sendKeys(obj[0][2]);
8
  • Holy crap. Selenium can pull data from Excel. I didn't know that, thanks. Commented Apr 22, 2017 at 19:06
  • What is the error it's giving you? Commented Apr 22, 2017 at 19:09
  • @GlenPierce XLSDatatable_Connectivity is not a Selenium Class. He probably made the class himself or uses a library. Commented Apr 22, 2017 at 20:13
  • @swati It looks like bad design you're getting "Object" classes out of the excel sheet. There's no way to know what type of stuff you're trying to put into the textfield for us now. Could you clear up where the XLSDatatable_Connectivity class comes from? Commented Apr 22, 2017 at 20:16
  • @GlenPierce Selenium isn't pulling data from Excel. That's Java and some other library. Commented Apr 23, 2017 at 0:37

1 Answer 1

1

You should use @Dataprovider to pass your test data into test class. Please follow this Link

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.