Docker container unable to read screenshot files?

Hi all,

I am attempting to use the docker container to run my tests but I am having an issue with reading saved screenshots.

I have a custom keyword that will take a screen shot and compare with a screenshot I have previously saved. I am using the WebUiBuiltInKeywords.takeScreenshot keyword and passing it a relative path on where to save the screen shot. This path is “Screenshots/Map/screenshot.png

In the test itself, I can see that is is saving in the correct path but as soon as I try to read that file, I am getting the following error:
[ERROR] - javax.imageio.IIOException: Can’t read input file!

You can see the logs here:

[START] - Start action : Statement - imgToCompareWithOriginal = com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.takeScreenshot(“Screenshots/Map/screenshot.png”)

02-06-2018 09:33:18 PM - [PASSED] - Taking screenshot successfully

02-06-2018 09:33:18 PM - [END] - End action : Statement - imgToCompareWithOriginal = com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.takeScreenshot(“Screenshots/Map/screenshotcompare.png”)

02-06-2018 09:33:18 PM - [START] - Start action : com.utils.WebUICustomKeywords.compareImage

02-06-2018 09:33:18 PM - [ERROR] - javax.imageio.IIOException: Can’t read input file!

02-06-2018 09:33:18 PM - [END] - End action : com.utils.WebUICustomKeywords.compareImage

02-06-2018 09:33:18 PM - [ERROR] - Test {test case removed} FAILED because (of) org.codehaus.groovy.runtime.InvokerInvocationException: javax.imageio.IIOException: Can’t read input file!

Once the test is complete, The exception I am seeing has a different relative path than the one noted above. The path I am seeing in the exception is
“/katalon/katalon/project/Reports/Suites/Products/{ourproductnameremoved}/Map/DockerTest/20180206_213259/Screenshots/Map/screenshotcompare.png”.

It looks like it is adding the test suite to the relative path. Is there a way I can prevent this from happening or is there another suggestion that might fix my test?

I should also note, this test works just fine if I am not using the docker container.

Thanks in advance for any help I can get.

One minor edit to the original post above, the file name should be “screenshotcompare.png” in my examples above, not “screenshot.png” as I put in my first 2 references.

Hi Jeff H,

TakeScreenshot does not support relative path, so you have to pass in ABSOLUTE path. To combine both relative and absolute path, you can try this:

import com.kms.katalon.core.configuration.RunConfiguration
WebUI.takeScreenshot(RunConfiguration.getProjectDir() + '/Screenshots/Map/screenshotcompare.png')

Ana,

Thanks for the suggestion. That resolved my issue with running tests in my docker container!