想要使用 groovy 脚本将文本文件从本地驱动器复制到服务器位置。获取缺失方法异常
Want to copy text file from local drive to server location using groovy script. Getting missing method exception
下面是我的脚本:
def FilePath = testRunner.testCase.getPropertyValue("FOLDER_PATH")
def FileName = testRunner.testCase.getPropertyValue("FILE_NAME")
def file = new File(FilePath+"\"+FileName)
log.info(file)
def destination = testRunner.testCase.testSuite.project.getPropertyValue("FILE_DEPOSITORY")
log.info(destination)
if(file.exists())
{
file.copyfile(FileName,FilePath,destination)
} else
{
log.info("A file named " + FileName + " does not exisits at the path "+FilePath)
}
我得到以下异常:
groovy.lang.MissingMethodException:没有方法签名:java.io.File.copyfile() 适用于参数类型:(java.lang.String, java.lang.String, java.lang.String) 值:[filename, sourepath,目标路径] 可能的解决方案:第 15
行的 isFile() 错误
已在本地测试并正常工作,
def Source = testRunner.testCase.getPropertyValue("FOLDER_PATH")
def FileName = testRunner.testCase.getPropertyValue("FILE_NAME")
def AbsoluteSource = new File(Source + "\" + FileName)
def Destination = testRunner.testCase.getPropertyValue("DESTINATION")
def AbsoluteDestination = new File(Destination + "\" + FileName)
if (AbsoluteSource.exists()) {
AbsoluteDestination << AbsoluteSource.bytes
} else {
log.info("A file named " + FileName + " does not exisits at the path " + Source)
}
下面是我的脚本:
def FilePath = testRunner.testCase.getPropertyValue("FOLDER_PATH")
def FileName = testRunner.testCase.getPropertyValue("FILE_NAME")
def file = new File(FilePath+"\"+FileName)
log.info(file)
def destination = testRunner.testCase.testSuite.project.getPropertyValue("FILE_DEPOSITORY")
log.info(destination)
if(file.exists())
{
file.copyfile(FileName,FilePath,destination)
} else
{
log.info("A file named " + FileName + " does not exisits at the path "+FilePath)
}
我得到以下异常: groovy.lang.MissingMethodException:没有方法签名:java.io.File.copyfile() 适用于参数类型:(java.lang.String, java.lang.String, java.lang.String) 值:[filename, sourepath,目标路径] 可能的解决方案:第 15
行的 isFile() 错误已在本地测试并正常工作,
def Source = testRunner.testCase.getPropertyValue("FOLDER_PATH")
def FileName = testRunner.testCase.getPropertyValue("FILE_NAME")
def AbsoluteSource = new File(Source + "\" + FileName)
def Destination = testRunner.testCase.getPropertyValue("DESTINATION")
def AbsoluteDestination = new File(Destination + "\" + FileName)
if (AbsoluteSource.exists()) {
AbsoluteDestination << AbsoluteSource.bytes
} else {
log.info("A file named " + FileName + " does not exisits at the path " + Source)
}