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 :
Create test cases directly for the product dashboard.
Maintain separate test cases for different dashboard features.
@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.
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.
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.
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.
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.