Katalon loses vital code switching to/from Manual View (was Katalon issue Javascript)

In Katalon Studio, when using triple double quotes to define a multi-line string in Groovy, the triple double quotes are automatically replaced by a single double quote, which causes an issue when trying to keep the code as originally written.

The problem occurs because Katalon Studio’s Groovy parser interprets triple double quotes as a string literal and converts them to single double quotes, which alters the intended format of the JavaScript code.

Is there a way to prevent Katalon Studio from automatically converting the triple double quotes to single double quotes and keep the code exactly as written?

Alternatively, how can I work around this issue in Katalon Studio to maintain the original format of the JavaScript code defined within the triple double quotes?

Example :
my code for example like this :
def js = “”"
//code javascript 1
//code javascript 2
}
“”"
the issue katalon studio do :
def js = "
//code javascript 1
//code javascript 2
}
"

1 Like

Do not switch to Manual View, use only script view, and should be fine.

2 Likes

+1 to @anon46315158 .


I tried to reproduce the problem. I made a Test Case and wrote a code in the Script mode:

def js = """
    console.log("Hello, world!");
"""

println js

I switched from the Script mode to the Manual mode.

and, in the Manual mode, I altered the code a bit.

then I switched back from the Manual mode to the Script mode.

Then I found the triple quotations have been altered as

def js = '\n    console.log("Hello, world!");\n'

println(js)

WebUI.acceptAlert()

The problem was reproduced.


@tahirieljalil

There is no way to tell Katalon Studio to respect the your original code format.

The Manual mode serializes the whole of Test Case code in a code format which the Manual mode is designed to follow. Their code format is unique and is most probably different from the code format you like. The Manual mode does not know your preference for code format.

As long as you don’t switch the Test Case editor from the Script mode to the Manual mode, you won’t be bothered by this symptom. So, don’t do it.

2 Likes

This a category 1 bug (loss of user work/data).

@mike.verinder @albert.vu @vu.tran

3 Likes

Thanks for the heads up @Russ_Thomas
I’ll make sure it gets some eyes

1 Like

This is just one of many issues caused by switching between the views. The bug has always been there. My guess is, it’s not easy to recover from the switch TO manual and then BACK to Script (in manual view, code needs to be parsed and “conditioned” for the view template).

In which case, at the very least, a WARNING should popup:

This script contains formatted script code which may not be compatible with Manual View and will need to be removed. Do you wish to continue?
(Choose CANCEL to keep your original code in Script View)

@mike.verinder

1 Like

+1 Warning message could have been present

1 Like

no + vote from me. The warning message will be easily ignored.

It might be an excuse: “I warned you not to, but you did it”.

But it wont help people who haven’t experienced this symptom.

Experience only helps.

In Katalon Studio, Don’t switch from Script mode to Manual mode.

Or, they should be aware that their own code formatting won’t be respected by the Manual mode.

1 Like

Thanks, but sometimes it’s easier to add manual steps, and this issue should ideally be handled by Katalon itself. It’s not feasible to completely avoid using the manual view, as there are certain scenarios where using manual view is faster.

anyway thanks for your help :+1:

1 Like

OK. If you are going to use the Manual mode, then you should accept that your own code formatting in the Script mode will be no longer preserved.

If you can accept it, that’s fine. The code will stay syntactically valid and will work anyway.

1 Like

Well, I somehow agree with … but.
This feature (manual view) it is mostly for new users with almost zero coding experience.
Looks like you are a bit more experienced, since you are already at the level when you write some custom code … but a bit lazy (like me).
So, you should be already familiar with typing, e.g WS. and use the intellicence provided by the eclipse engine. Using Manual View from time to time will only confuse you.

On the other side, yeah, this bug is valid and it is there since centuries.
It was reported many times in many ways.
Switching from one view to the other should not alter the existing code.
But I doubt it is an easy fix for it.

1 Like

Mhm…
well, i propose another option.
Since the katalon ‘engine’ detects this somehow and do some action, instead of rising a warning it should notify the user ‘cannot parse this code block properly’ and give the user the choice between keeping the code block or re-format

1 Like

I don’t think that they can implement this.

1 Like

Neither I, but let’s see if the development team pick-up the challenge.
Impossible is nothing!
I have some ideas how this can be achieved but let them ask, or do a brainstorm

1 Like

Let me reword this.

I don’t think that they would challenge this.

I think so because of a cost & benefit consideration. It’s just a bit of uglification. The reformatted code works without error.

1 Like

Hi @Elly_Tran,

Could you submit a bug report ticket to our Product team about @tahirieljalil’s issue? Thanks em.

2 Likes

I personally do not mind this issue much because I never use the Manual mode.

I always import many external libraries other than com.kms.katalon.core.*. The Manual mode is not designed to present those “non Katalon-native” code properly. Let me show you an example how my sample test case is displayed in Manual mode.

A long sequence of Binary Statement and Method Call Statement which intentionally hides the data type declarations of variables (String, float, BufferedImage). This presentation make me very frustrated. I would say that Manual mode with non Katalon-native factors is ugly.

The same test case in Script mode is presented like this:

import java.awt.image.BufferedImage

import javax.imageio.ImageIO

import org.openqa.selenium.By
import org.openqa.selenium.WebDriver

import com.kazurayam.ashotwrapper.AShotWrapper
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

WebUI.openBrowser('')
WebUI.setViewPortSize(1000,1000)
WebUI.navigateToUrl('https://forum.katalon.com/')

WebDriver driver = DriverFactory.getWebDriver()
String xpath = "//div[@id='list-area']"

float dpr = AShotWrapper.DevicePixelRatioResolver.resolveDPR(driver)
AShotWrapper.Options options = new AShotWrapper.Options.Builder().devicePixelRatio(dpr).build()

BufferedImage image = AShotWrapper.takeElementImage(driver, By.xpath(xpath), options)
assert image != null

File file = new File("./element_screenshot.png")
ImageIO.write(image, "PNG", file)

driver.quit()

I feel relieved by the source code presented as text.

Thus I don’t use Manual mode. So I am free from the original problem (Katalon loses vital code switching to/from Manual View).

1 Like

Which is the point of the message/alert.

Huh? It’s simple, to the point advice. :roll_eyes:

1 Like

To be totally free, simple dont use katalon.
So i don’t see your point here.
We help somehow the development team with how to improve it, or we create a library with workarounds?

1 Like