Read Test Data from Excel


#1

Hi,

I am trying to read data from an excel file at Test case level.

I am able to read test data from excel ( from sheet 1).

I also have test data in sheet 2 of the excel file which I need to read in the same test case. How can I do this?

Please let me know.

Thanks,
Umakant


#2

hello,

depends on how your script will read excel?

read again with another sheet name as parameter
you have to implement keyword where the sheet name is used as parameter

	@Keyword
	public List<String> readExcelRows(int start, int end, String path, sheetName) throws IOException, InvalidFormatException{

		SAMPLE_XLSX_FILE_PATH = path;
            workbook = WorkbookFactory.create(new File(SAMPLE_XLSX_FILE_PATH));

		// Getting the Sheet as sheetName
		Sheet sheet = workbook.getSheet(sheetName);

#3

Thanks Timo for your help!!!

I was using findTestData( ) and getValue( ) methods from katalon studio API.

below is snippet:

    WebUI.setText(findTestObject('Object Repository/Page_Login  Salesforce/input_Username_username'), findTestData('Automation Test Data').getValue(
            'UserName', 1))
    WebUI.setEncryptedText(findTestObject('Object Repository/Page_Login  Salesforce/input_Password_pw'), findTestData('Automation Test Data').getValue(
            'Password', 1))

If I have to use them and also read the data from another sheet, Do i need to create a custom getValue( ) method with sheet as parameter? OR does katalon studio API has a predefined method to perform this task.

Please let me know.


#4

Hi @umas181929

There’s no native API in katalon to help read values from different sheets. However, there’s a Read Write Excel Custom Keyword Plugin that may interest you.

https://store.katalon.com/product/34/Read-Write-Excel-Custom-Keywords

Cheers !


#5

Hi Umakant,

Kindly see the link below… You can read in different excel sheets using this approach. . .

Hope that helps. . . :slight_smile:


#6

hi you,

`I am not using Katalon excel plugin, I have implemented own excel read / write keywords to my use, with this way i’ll get just that how I will use the excel functions
:smile: