swati
swati

Reputation: 9

selenium code to fetch data from excel

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]);

Upvotes: 0

Views: 790

Answers (1)

jithinkmatthew
jithinkmatthew

Reputation: 930

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

Upvotes: 1

Related Questions