Not able to take screenshot and maximize window

Not able to take screenshot and maximize window. I was able to do it when I run the test suite from my local, but running the same test suite from jenkins is getting stuck at maximize window and take screenshot line.

Attaching the logs:
logs.txt (49.4 KB)

hello,

can you describe more how your screenshots are implemented? and why have to use max window size?
some snip from code would be nice

Here is the code snippet:

WebUI.openBrowser(’’)
WebUI.maximizeWindow()
WebUI.navigateToUrl(GlobalVariable.baseURL)

and for screenshot i am using:
WebUI.takeScreenshot()

Katalon is even giving timeout for taking snapshot in case of failed test case.

For maximizing window for Jenkins execution you will need to use chrome desired capabilities…

(how to set them up are in the screenshot)

But I am would also like to know how can we take screenshots within Jenkins execution?
@devalex88 @kazurayam
I am using WebUI.takescreenshots and saving them in the folder of latest run (in report/XYZ) but it looks like when I execute tests using KS docker image screenshots are not saved and copied back to Jenkins while other files in the report folder are copied successfully.
Is it possible to take screenshots during Jenkins execution? (the logs do not produce any errors and everything looks like it was successful)

1 Like

OK I got it…
after quick debugging I realized that how we build a path is different between local (windows) and Jenkins (linux) environment so \ should be replaced with / and then everything worked…

so this is what I need for Linux (Jenkins)
String fileName = RunConfiguration.getReportFolder() + “/FirstImage.jpg”
println(“fileName1:” + fileName)
WebUI.takeScreenshot(fileName)

and this is what works for Windows (Local) environment (note \\)
String fileName = RunConfiguration.getReportFolder() + “\\FirstImage.jpg”
println(“fileName1:” + fileName)
WebUI.takeScreenshot(fileName)

1 Like

You should not write platform specific separator (‘/’ or ‘\’) in scripts. Hard coding ‘/’ or ‘\’ makes your script less portable. Script with ‘/’ does not work on Windows, script with ‘\’ does not work on Mac and Linux. You should rather use java.io.File.separator. For example:

String fileName = RunConfiguration.getReportFolder() + File.separator + "FirstImage.jpg”
2 Likes

100% agree… thanks!

1 Like