Unable to apply global directory file storage path in 6.0.5

I just upgraded to 6.0.5 and the global variable I have set up to define a directory structure for screenshots (suggested in this forum), is suddenly no longer working. Any ideas why? 2019-03-07_16-59-04

Error details:
2019-03-07 16:55:03.006 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ com.kms.katalon.core.exception.KatalonRuntimeException: Could not evaluate default value for variable: imgDir of profile: PX. Details: No such property: RunConfiguration for class: Script13e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.getGlobalVariables(TestCaseMain.java:186)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$getGlobalVariables$1.call(Unknown Source)e[0;39m
e[31m at internal.GlobalVariable.(GlobalVariable.groovy:148)e[0;39m
e[31m at Script2.run(Script2.groovy:1)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptWithoutLogging(ScriptEngine.java:105)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.lambda$0(TestCaseExecutor.java:383)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.collectTestCaseVariables(TestCaseExecutor.java:370)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.processScriptPreparationPhase(TestCaseExecutor.java:152)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:205)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)e[0;39m
e[31m at TempTestCase1551995699863.run(TempTestCase1551995699863.groovy:21)e[0;39m
e[31mCaused by: groovy.lang.MissingPropertyException: No such property: RunConfiguration for class: Script13e[0;39m
e[31m at Script13.run(Script13.groovy:1)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptWithoutLogging(ScriptEngine.java:105)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.getGlobalVariables(TestCaseMain.java:184)e[0;39m
e[31m … 12 more

Are you importing RunConfiguration?

import com.kms.katalon.core.configuration.RunConfiguration

I use it in 6.0.5 in every Test execution and it’s working fine here.

Yeah, I have import com.kms.katalon.core.configuration.RunConfiguration set in the start of my script. Whyyyyy… :thinking:

What I am finding quite odd is my </> Script View for Globals is completely empty in 6.0.5… hmmm

Fixed in next release. Actually, you can get it early if you’re willing to try the beta: [Updated - Mar 8th] Beta release 6.0.6

Might need to show us more of your code…

I’ll give it a go - thanks!

Bah… it’s still failing but at least I can see the variables in script mode. Test case fails right at the start:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import java.time.LocalDateTime
import java.time.format.DateTimeFormatter
import com.kms.katalon.core.configuration.RunConfiguration
import java.io.File
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths

// Define dateTime variable (used for folder naming structure)
LocalDateTime now = LocalDateTime.now()
dateTime = DateTimeFormatter.ofPattern(“yyyyMMdd_HHmmss”).format(now)

// Create screenshot folder
String path = (imgDir + dateTime + File.separator)
Path outputDir = Paths.get(path)
Files.createDirectories(outputDir)
GlobalVariable.filepath = path


imgDir is pointed to a Global Variable which is defined as:
imgDir RunConfiguration.getProjectDir() + ‘/Reports/Screenshots/PX/’

Script seems to be barfing on the global variable definition (this was working flawlessly until I upgraded, not sure what happened!).

Error again:
2019-03-07 17:45:19.453 e[1;31mERRORe[0;39m e[36mc.k.katalon.core.main.TestCaseExecutor -e[0;39m e[31m❌ com.kms.katalon.core.exception.KatalonRuntimeException: Could not evaluate default value for variable: imgDir of profile: PX. Details: No such property: RunConfiguration for class: Script13e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.getGlobalVariables(TestCaseMain.java:186)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$getGlobalVariables$1.call(Unknown Source)e[0;39m
e[31m at internal.GlobalVariable.(GlobalVariable.groovy:148)e[0;39m
e[31m at Script2.run(Script2.groovy:1)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptWithoutLogging(ScriptEngine.java:105)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.lambda$0(TestCaseExecutor.java:383)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.collectTestCaseVariables(TestCaseExecutor.java:370)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.processScriptPreparationPhase(TestCaseExecutor.java:152)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:205)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)e[0;39m
e[31m at TempTestCase1551998716280.run(TempTestCase1551998716280.groovy:21)e[0;39m
e[31mCaused by: groovy.lang.MissingPropertyException: No such property: RunConfiguration for class: Script13e[0;39m
e[31m at Script13.run(Script13.groovy:1)e[0;39m
e[31m at com.kms.katalon.core.main.ScriptEngine.runScriptWithoutLogging(ScriptEngine.java:105)e[0;39m
e[31m at com.kms.katalon.core.main.TestCaseMain.getGlobalVariables(TestCaseMain.java:184)e[0;39m
e[31m … 12 more

Appreciate the help!
Morgan

Using a GV is not your only option here. You could call a static somewhere early (test listener?) and set a global of your own which you import “everywhere”. IOW, create a proper var in your own keyword class and leave GVs out of the picture.

Interesting. Just re-downloaded 5.10.1 and the same piece of code works without issue. Strange! Well, like you said, there are other ways around it. Thanks for the help!

@devalex88 @YoungNgo

Sorry if this has been reported before but you should probably fix this one asap (if only because a downgrade to 510 fixes the issue).

2 Likes

Hi @Morgan

Please change RunConfiguration to com.kms.katalon.core.configuration.RunConfiguration. Btw, we will re-enable this default import in next release.

Thanks

2 Likes

Im having same issue