Hello, when I try to execute this customer keyword:
@Keyword
public boolean isFileDownloaded(String downloadPath, String fileName) {
File dir = new File(downloadPath);
File[] dirContents = dir.listFiles();
String lastAttempt = "";
if (dirContents.length > 0) {
for (int i = 0; i < dirContents.length; i++) {
if (dirContents[i].getName().equals(fileName)) {
// File has been found, it can now be deleted:
dirContents[i].delete();
KeywordUtil.markPassed(fileName + ' exist in ' + downloadPath + ' and was deleted')
return true;
}
lastAttempt = dirContents[i].getName().equals(fileName);
}
if (lastAttempt != fileName) {
KeywordUtil.markFailed(fileName + 'does not exist in' + downloadPath)
return false;
}
}
return false;
}
And when I execute I go the title error: java.lang.NullPointerException: Cannot get property ‘length’ on null object and I don’t know how to handle this. Thank you in advanced!