SmartBear/SoapUI5.2.1 opensource: problem with "... No signature of method: java.io.File.exist()
Thanks, in advance.
Story: I am trying to See if a file exists on the Network drive, then Delete it.
A- I have commented out most lines to narrow down the issue.
B- I could not find a working example code in Groovy either.
1. In SoapUI 5.2.1, set the Script Language t- JavaScript.
2. Execute the attached script.
It results in: "groovy.lang.MissingMethodException: No signature of method: java.io.File.exist() is applicable for argument types: () values: [] Possible solutions: exists(), list(), list(java.io.FilenameFilter), wait(), wait(long), print(java.lang.Object) error at line: 9 "
=========
def xmlfilepath = new File ('\\\\sharedNET\\Mirth\\QA\\External\\HTTPS\\myfile.xml') ;
def IDXfilepath = new File ('\\\\Shareddevice\\c$\\SFTP\\Dest\\QA\\Results\\myfile.idx') ;
//var xmlfilepath = '\\\\sharedNet\\Mirth\\QA\\External\\HTTPS\\myfile.xml' ;
//var IDXfilepath = '\\\\SharedDevice\\c$\\SFTP\\Dest\\QA\\Results\\myfile.idx' ;
log.info(xmlfilepath);
log.info(IDXfilepath);
if (xmlfilepath.exist() ){
// file exist
log.info("XML file exist");
delete (xmlfilepath);
//xmlfilepath.delete(xmlfilepath);
}
if (!xmlfilepath.exists() ) {
// file is not exist
Log.info("XML file does not exist");
}
//if ( IDXfilepath.exists() ){
// file exist
// Log.info('IDX file exist');
// IDXfilepath.delete();
//}
//if (!IDXfilepath.exists()) {
// file is not exist
// log.info("IDX file does not exist");
//}
============
The groovy script for your goal is following:
def f = new File('//server/path/test.txt') if (f.exists()) { f.delete() }
You can use Javascript as well. SoapUI is a bit tricky with changing the scripting language. When I change from Groovy to Javascript (on project level), I can use Javascript. When I switch back to Groovy, the script is still executed as Javascript.
I had to close the test case editor and reload the project. Then the script is executed by the language which is set on the project.