Can't generate test cases on Katalon studio

Hi all ,

I can’t able to generate the test case using spy web. Whenever i can go to the spy web , it is opening in new tab and I am login again and again. I want that i do not want to login againa and agin in my dashboard , once i have login , my test case start generating from that step , else it is showing “Test Case Failed“ and also , my requirement is :

  1. Create test cases directly for the product dashboard.
  2. Maintain separate test cases for different dashboard features.
  3. Avoid logging in every time.

1 Like

Hi there, and thanks for posting in the Katalon community! :hugs:

To help you faster, please review our guide on Spy Web Utitliy here: Spy Web utility in Katalon Studio | Katalon Docs. Double-checking the steps and configurations might resolve the issue.

If the doc doesn’t help, feel free to provide more details, and a community member will assist you soon.

Thanks for being a part of our community!
Best,
Elly Tran

@rohit.kawatra

The Spy Web is only for capturing the Test Objects on your web app.

You should use the ‘Record Web’ option for recording and generating test cases.

@rohit.kawatra Spy web is not used to record test, is it used to inspect, capture and add web UI elements (test objects) into your Object Repository.
Use record web feature to record the test.

But there is definitely there is some issue with active browser, it is not working properly. I am creating another tkt for that

I had a look at the movie @rohit.kawatra attached to the original post.

No, @rohit.kawatra did NOT launch the Spy Web tool at all. Perhaps, he does not understand what Spy Web means.

He just ran a Test Case script by clicking the run_katalon_test green button.

So the advices to him concerning “Spy Web” are pointless.

1 Like

What do you mean by the word “the product dashboard”?
I have no idea what you mean by this word.
You should explain what it is.
The best way would be sharing the public URL of “a product dashbord” you meant.

@rohit.kawatra wrote:

If I am right, I would reword this statement as follows.

  • @rohit wants to generate Test Case scripts using the Record Web tool.
  • @rohit wants to generate two or more scripts. One for a “dashbord A”, another for a “dashbord B”, and so on.
  • @rohit made some test cases and realized that every generated scripts start with the same Login procedure.
  • The Login procudre is long, complicated and bug-prone.
  • @rohit does not like to duplicate the steps that perform the Login procedure in many test case scripts.

I guess that @rohit.kawatra wants to know how to avoid the code duplications in his test case scripts.

Just to give an idea to @rohit.kawatra, I would describe some about the Katalon’s sample project “healthcare-tests”.

I would suggest @rohit.kawatra to read the doc and run through the sample project on his machine locally.

Especially, see the Main Test Cases/TC2_Verify Successful Appointment. I will quote the source here for your reference:

WebUI.comment('Story: Book an appointment')
WebUI.comment('Given that the user has logged into their account')
WebUI.openBrowser(GlobalVariable.G_SiteURL)

/* 
 * The Login procedure is modularized and externalized
 */
WebUI.callTestCase(findTestCase('Common Test Cases/Login'), [('Username') : 'John Doe', ('Password') : 'ThisIsNotAPassword'], 
    FailureHandling.STOP_ON_FAILURE)

WebUI.comment('And Appointment page is displayed')
if (true) {     WebUI.selectOptionByLabel(findTestObject('Page_CuraAppointment/lst_Facility'), 'Hongkong CURA Healthcare Center', false)
    WebUI.check(findTestObject('Page_CuraAppointment/chk_Medicaid'))   WebUI.check(findTestObject('Page_CuraAppointment/chk_Readmission'))
    WebUI.setText(findTestObject('Page_CuraAppointment/txt_VisitDate'), '27/12/2016')
    WebUI.setText(findTestObject('Page_CuraAppointment/txt_Comment'), 'Please make appointment as soon as possible.')
}
WebUI.comment('When he fills in valid information in Appointment page')
WebUI.click(findTestObject('Page_CuraAppointment/btn_BookAppointment'))
WebUI.verifyTextPresent('Appointment Confirmation', false)
WebUI.comment('Then he should be able to book a new appointment')
if (true) {
    WebUI.verifyMatch('Hongkong CURA Healthcare Center', WebUI.getText(findTestObject('Page_AppointmentConfirmation/lbl_Facility')), false)
    WebUI.verifyMatch('Yes', WebUI.getText(findTestObject('Page_AppointmentConfirmation/lbl_HospitalReadmission')), false)
    WebUI.verifyMatch('Medicaid', WebUI.getText(findTestObject('Page_AppointmentConfirmation/lbl_Program')), false)
    WebUI.verifyMatch('27/12/2016', WebUI.getText(findTestObject('Page_AppointmentConfirmation/lbl_VisitDate')), false)
    WebUI.verifyMatch('Please make appointment as soon as possible.', WebUI.getText(findTestObject('Page_AppointmentConfirmation/lbl_Comment')), false)
}
WebUI.takeScreenshot()
WebUI.closeBrowser()

Please find that the Login procedure is modularized and externalized to be 'Common Test Cases/Login'.

This sample code demonstrates how to modularize some portion of steps in Test Case in order to avoid code duplication.

Katalon’s “Web Recorder” tool does not generate any scripts with modularization implemented. Rather, you need to be able to mamually rewrite the generated script to be modularized. In other words, you are required to be a good programmer.

I am trying to do it from record web as well , in that I am facing same issue my login screen captures multiple times but i want it should be consider only one time and if i overwrite the current test case , it should be restart again from login , which i can’t want.

So , it will be very grateful if you tell the solution for this.

No, I can’t.

You need to edit your test case scripts manually using the “Test Case editor” in “Script view”.

You should not expect much out of the Record Web tool. It is a dum tool. It is not as sophisticated as you expect. Yes, it helps you getting started with automating web UI tests. But no more. Once you finished generating a Test Case script using “Record Web” tool, then you should stop using it. You should switch yourself to scripting manually. Don’t continue relying on the tool as it will always overwrite your artifacts.

Disappointed?

Now you learned the fact. Will you go on Katalon Studio or abandon it? It is up to you.

2 Likes

The following post may interest you:

If you only use the recording tools of KS, then you have to “record” your login every single time. When you eventually want to, you can start using KS in other ways, such as like @kazurayam suggests. I will show you another method as well.

Maybe like:

Kazurayam suggests using a called Test Case, which I also use in other instances, but for my simple login, I just use a Keyword.


WebUI.openBrowser(GlobalVariable.gSiteURL)
WebUI.waitForPageLoad(10)

WebUI.maximizeWindow()

"sign into the application"
CustomKeywords.'com.Tools.signIntoAX'(GlobalVariable.gTestIdPathWay)

"make sure we are on our interface"
CustomKeywords.'com.Review.reviewCompanyChooser'()

WebUI.waitForElementVisible(findTestObject('Dashboard Page/span_Modules'), 10)
```

and then I go into the rest of my testing script.
For my Keyword, it is a simple script:
```
/**
 * sign into ax using the references in the spreadsheet
 */
@Keyword
def signIntoAX(String pathway) {
    // get username and password from spreadsheet
	FileInputStream fis = new FileInputStream (pathway)
	XSSFWorkbook workbook = new XSSFWorkbook (fis)

	XSSFSheet sheet = workbook.getSheet("Sheet1")

	// cell A2
	Row row = sheet.getRow(1)
	Cell cell = row.getCell(0)
	GlobalVariable.gUsername = cell.getStringCellValue()

	// cell A3
	row = sheet.getRow(2)
	cell = row.getCell(0)
	GlobalVariable.gPassword = cell.getStringCellValue()

	fis.close()

	//		WebUI.comment(GlobalVariable.gUsername)
	//		WebUI.comment(GlobalVariable.gPassword)

    WebUI.waitForElementVisible(findTestObject('Main Login Page/input_Sign in_UserName'), 10)
	WebUI.setText(findTestObject('Main Login Page/input_Sign in_UserName'), GlobalVariable.gUsername)
	WebUI.verifyElementAttributeValue(findTestObject('Main Login Page/input_Sign in_UserName'), "value", GlobalVariable.gUsername, 10)

    WebUI.verifyElementVisible(findTestObject('Main Login Page/input_Sign in_Password'))
	WebUI.setEncryptedText(findTestObject('Main Login Page/input_Sign in_Password'), GlobalVariable.gPassword)

    WebUI.verifyElementVisible(findTestObject('Main Login Page/span_Sign in'))
	WebUI.click(findTestObject('Main Login Page/span_Sign in'))
	WebUI.waitForPageLoad(10)
}
```

Edit: and you can see you only have “click” commands in your script, whereas I am using “verify” and “wait” commands. The Web Spy and the Web Recorder do not record “verify” or “wait” commands, but only simple mouse click events.

As @grylion54 pointed out, the “Record Web” tool does not generate “verify” or “wait” commands automatically. Without the “wait” as guard, the “WebUI.click” is likely to cause errors like com.kms.katalon.core.webui.exception.WebElementNotFoundException. This is a common pitfall that newcomers to Katalon get stuck. In order to fix the errors, you need to insert “verify” or “wait” commands manually after the “WebUI.click” commands into the scripts. I mean, you will be required to imrove the code manually anyway.

You should not expect that the tool will generate 100% correct and completely working codes. A generated code is just a dessin. Code generation is just the start of long way for you to develop your tests.

Please note that, when I write “Record Web”, I mean the non-AI-backed one available for free. I have no idea how brilliant the StudioAssist is. I don’t know if the AI-backed tool can generate scripts well modularized, if it inserts “wait” commands appropriately. Please check it yourself.