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.
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?
my code for example like this :
def js = “”"
the issue katalon studio do :
def js = "
Do not switch to Manual View, use only script view, and should be fine.
+1 to @bionel .
I tried to reproduce the problem. I made a Test Case and wrote a code in the Script mode:
def 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'
The problem was reproduced.
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.
This a category 1 bug (loss of user work/data).
@mike.verinder @albert.vu @vu.tran
Thanks for the heads up @Russ_Thomas
I’ll make sure it gets some eyes
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)
+1 Warning message could have been present
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.
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
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.
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.
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
I don’t think that they can implement this.
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
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.
Could you submit a bug report ticket to our Product team about @tahirieljalil’s issue? Thanks em.
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 com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
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)
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).
Which is the point of the message/alert.
Huh? It’s simple, to the point advice.
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?