How to read values from another sheet in Test data Excel sheet

I am using an Excel sheet with two tabs (sheets) as a test data source. I have uploaded the Excel file under “Data Files”. The Sheet Name is defaulted to “Sheet1” but I need data from “Sheet2”.
My script is below:

TestData data = findTestData(‘Test data master’).changeSheet(‘Sheet2’)
log.logInfo(data.internallyGetValue(‘Amount’, 1))

It returns null so I assume that “changeSheet” function is not working.

Reason:
java.lang.NullPointerException: Cannot invoke method internallyGetValue() on null object

1 Like

Hi @Evan

Here’s a related problem

From this I think the problem is that changeSheet is a void method and does not return anything, therefore data is null. Please try this:

TestData data = findTestData(‘Test data master’)
data.changeSheet('Sheet2')
log.logInfo(data.internallyGetValue('Amount', 1))

Hi Evan,

You can refer to this link:

Hope that helps. . . :slight_smile:

2 Likes