uiValidator.generateReport hangs on Windows 10
Both https://github.com/ITArray/automotion-appium-example and https://github.com/ITArray/automotion-selenium-example examples hang when executing uiValidator.generateReport method. After the hanging, the CPU load by Java process is increased to about 30% and then remains until the Java process killing. No reports are generated.
It does not matter whether the test launched via Maven or via IDE. It does not matter which Windows 10 edition(Home or Pro) is used. Note that the same noticed examples work smoothly on Ubuntu 16.04 LTS, so it seems to be an OS-depended bug.
Tried the automotion-java 2.1.1 - unfortunately it did not help - the behaviour is the same :( But when I tried step-by-step execution of the generateReport method call - I found an infinite loop in \net\itarray\automotion\internal\HtmlReportBuilder.java while(true) { if (!file.delete()) { continue; } } "!file.delete()" always returned False. And when I tried to delete the file manually via file manager - the Windows says that the file is used by another process so cannot be deleted. Perhaps the file was not closed after creation? The mentioned file name is like TopSlider-automotion153063307014199b5470.json
Performing step-by-step debug, I found the following line in https://github.com/ITArray/automotion-java/blob/master/src/main/java/net/itarray/automotion/internal/HtmlReportBuilder.java :
Object obj = parser.parse(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
In this line, the FileInputStream is opened, and remains opened when the following line executed:
while (!file.delete()) ;
Therefore Windows failed trying to delete the opened file. I don't really know how the deletion works in *nix, but anyway, Windows does not allow such deletion.
Then I made the following change:
// Object obj = parser.parse(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
Object obj;
try(InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8)){
obj = parser.parse(inputStreamReader);
}
Then I built automotion-2.1.0.jar locally and connected this .jar to automotion-selenium-example project. Finally, when running automotion-selenium-example project - it does not hang and generates reports. So it seems like a working fix.
I tried to create pull request, but didn't managed to push my branch to remote. So Denys, if you OK with the change - could you please implement the update?