# ScriptView \> ManualView \> ScriptView

**URL:** <https://forum.katalon.com/t/scriptview-manualview-scriptview/57428>\
**Category:** Bug Report\
**Tags:** tracked, bugs-report, katalon-studio\
**Created:** [August 13, 2021, 3:39pm UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428 "2021-08-13T15:39:53Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [August 13, 2021, 3:39pm UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/1 "2021-08-13T15:39:53Z")

</div>

@ThanhTo @duyluong This has been a bug since _forever_. It’s well documented here somewhere, but here’s what I saw just now…

Switching between Manual View and Script view _can_ trash your script. Manual View tries to format the code and sometimes gets it horribly wrong. I just tried it again now, because it’s been so long since I went in there – and puff! A half dozen lines managed to survive while the other 50+ lines were trashed. Thankfully I had a backup.

Here’s a minimal STR:

Create a simplistic script.

```auto
import something
import something_else

class my_class {

  my_class() {
    println("my_class")
  }
} 

try {
  new my_class() 
} catch(Exception e) {
  println(e.message)
}

```

Visit Manual View.  
Add a custom keyword (I used the first one in the list).  
Return to Script View.  
Bang.

```auto
import something as something
import something_else as something_else
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import internal.GlobalVariable as GlobalVariable

try {
    new my_class()
}
catch (Exception e) {
    println(e.message)
} 

CustomKeywords.'com.kms.katalon.keyword.applitools.BasicKeywords.checkElement'(null, null)

```

What just happened?

It deleted the class my\_class.  
(And added way too many unnecessary imports).

---

<div class="post-metadata">

**Author:** ![Gecko](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/gecko/32/16104_2.png) [@Gecko](https://forum.katalon.com/u/Gecko)\
**Post date:** [August 13, 2021, 5:22pm UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/2 "2021-08-13T17:22:32Z")

</div>

Interesting.

I think one basic aspect here is the way, you use the test case scripting mode. As far as I understand Katalon Studio, it’s not meant to be used like that. The scripting mode should not contain class definitions or anything that is not well representable in the manual mode, right? It should only have content that can be represented in a _line wise manner that fits to the manual mode (i.e. there is a representation of the script in the manual view, as it is the case with your try-catch phrase)_. The rest of the script should go to the keyword nodes. At least this is how I experience these two test modes (scripting and manual) to work well together.

Let’s not forget: The test cases are meant to be used by manual testers supported by developers - at least this is the total nature of Katalon Studio, right? If you want to do massive scripting without the support of test engineers working with the manual mode, you would be well advised to go straight for a core selenium project or maybe a tool that wraps selenium for developers nicely, like Ranorex Webtestit, for example.

But of course, you _did_ report something that should be viewed as a bug. Katalon Studio should definitely not mess with script content, but give out a clear warning if script content is not compatible with the manual mode.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [August 13, 2021, 6:04pm UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/3 "2021-08-13T18:04:32Z")

</div>

> [@Gecko](#):
>
> The scripting mode should not contain class definitions or anything that is not well representable in the manual mode, right?

It’s Groovy. It should work.

A script is a script-class. A class can contain a class. End of story.

> [@Gecko](#):
>
> It should only have content that can be represented in a _line wise manner_

Nope. That’s your baggage, not how Katalon/Groovy works.

> [@Gecko](#):
>
> The rest of the script should go to the keyword nodes

I don’t know what that is.

> [@Gecko](#):
>
> Let’s not forget: The test cases are meant to be used by manual testers supported by developers - at least this is the total nature of Katalon Studio, right?

You’re restricting how it can be used when you say that.

---

<div class="post-metadata">

**Author:** ![Brandon\_Hein](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/brandon_hein/32/1092_2.png) [@Brandon\_Hein](https://forum.katalon.com/u/Brandon_Hein)\
**Post date:** [August 13, 2021, 8:49pm UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/4 "2021-08-13T20:49:38Z")

</div>

Yeah, this is a pretty serious bug, and I think there have been other reports of it floating around, where people mysteriously lose data without any apparent cause. It’s good you were able to find a reproduceable scenario for it.

I’ve always suspected that Katalon generates scripts using _reflection_, and that’s why, for each script you write, Katalon generates a “.tc” file as well as a “Script0123456789.groovy” file. Not sure if that’s actually what’s happening behind the scenes, just a guess, but I wouldn’t be surprised if the bug lives within this process.

---

<div class="post-metadata">

**Author:** ![Gecko](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/gecko/32/16104_2.png) [@Gecko](https://forum.katalon.com/u/Gecko)\
**Post date:** [August 16, 2021, 7:29am UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/5 "2021-08-16T07:29:10Z")

</div>

> [@Russ\_Thomas](#):
>
> > [@Gecko](#):
> >
> > The rest of the script should go to the keyword nodes
> 
> I don’t know what that is.

 ![katalon-tree](https://europe1.discourse-cdn.com/katalon/original/3X/3/d/3d28eb14a7170f26d154e9ee699b8454d665163b.png)  
Please see that image. This is the Katalon tree in version 8.0.5. It has a “Keywords” and a “Test Cases” node. I think, you are basically right by reporting this bug, but I wonder why you would create a class under the test cases node, when you could also create it under the keywords node, where it makes so much more sense (at least to me 😉 ).

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [August 16, 2021, 12:35pm UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/6 "2021-08-16T12:35:05Z")

</div>

> [@Gecko](#):
>
> I think, you are basically right by reporting this bug[…]

Gee. Thanks.

> [@Gecko](#):
>
> but I wonder why you would create a class under the test cases node

“Why” questions can lead to turtles, all the way down. So, with the proviso we stick with the topmost turtle and leave it at that…

OO \> POM \> DRY.

---

<div class="post-metadata">

**Author:** ![Shin](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/shin/32/16552_2.png) [@Shin](https://forum.katalon.com/u/Shin)\
**Post date:** [August 24, 2021, 8:27am UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/7 "2021-08-24T08:27:43Z")

</div>



---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [August 24, 2022, 8:28am UTC](https://forum.katalon.com/t/scriptview-manualview-scriptview/57428/8 "2022-08-24T08:28:15Z")

</div>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
