Can I get API url from data files (Data driven approach)

Hi,

We have like thousand of json files with one end point but multiple (thousand of json files).
e.g.

Is it possible to get the json file from data files (Test Data)?
sample
image

if not, what is the work around for this?

so that i can request http://endpoint/all/TEST_I.json

What do you mean by “get the json file”? Get its name? Get its content?

get its name so that i can put it in the api url. :slight_smile:

Hi @angelo.dabu

My post can help: How to use Global Variable directly in Object Repository URL

  1. Add Global Variable in Profile (“G_fileName”).
  2. Add Local Variable (“file” - to match yours URL) in request definition (Object Repository) and set type “Global Variable”. Select Global Variable, created in 1. in Default Value. This will link Local with Global.
  3. Loop in TC.

Code not tested, it is just idea:

import com.kms.katalon.core.testdata.TestDataFactory
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

myData = TestDataFactory.findTestData('listOfFiles')
myData.allData.forEach()
{
	GlobalVariable.G_fileName = it[1] //Yes you will get array
	res = WS.sendRequest(findTestObject('fileRequestName'))
	//Do what you need with res
}
1 Like