Passing Object Names as String Variables in Katalon Studio
While working on a Custom Keyword, I noted the code could be even more modular if I was able to pass in the object name. It doesn’t need to be an object, just the path to the object in the Object Repository. As a simple example, take the code to read the value from a Select or Input field. The code is the same except for the referenced object. The code would look like: int resultsPerPage=WebUI.getAttribute(findTestObject(‘Sales Data/Sales Table/select-Results Per Page’),’value’).toInteger() With that in mind, we could create a variable with the path, then call the Custom Keyword with that variable. The code would then look like: objectPath=”Sales Data/Sales Table/select-Results Per Page” CustomKeywords.’commonCode.DataCollection.getResults'(objectPath) We could then change the path and call the Keyword again, still using the same code. As a slightly more involved example, we have a page with three sets of filters. Each row has a different definition which meant three objects in the repository. When setting up code […]
Recent Comments