Dataprovider in selenium webdriver
Using Dataprovider annotation to read the data from excel, we have to pass all the columns in the excel sheet as the parameters to the method (i.e : if there are 100 columns in the excel sheet, we have to pass 100 parameters to the data provider method), which is not a good pactice, so please let me know any other way to read the data from excel, which should repeat the number of times the rows are present in excel sheet
I think you can try like this:
– Read the data from excel using Apache POI or any other parser.
– Put the data into a Hashtable.
– Now put the hashtable into an object array.
– Use that object array in your @DataProvider method.
– Pass the hashtable data to your @Test method which is using the above dataprovider.
– You can access the values by invoking ‘get’ method on ‘Hashtable’ class on prividing the keys.