Skip to content

Commit

Permalink
#3 add TC0, modified TC1 and TC2
Browse files Browse the repository at this point in the history
  • Loading branch information
kazurayam committed Nov 26, 2024
1 parent 99d03e1 commit 49d411a
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 63 deletions.
63 changes: 63 additions & 0 deletions Scripts/TC0/Script1732526297013.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

/**
* This script visits the page at https://katalon-demo-cura.herokuapp.com/ and the linked pages
* without highlighting elements
*/

// open browser and navigate to the AUT
WebUI.openBrowser('')
WebUI.setViewPortSize(1024, 768)
WebUI.navigateToUrl('https://katalon-demo-cura.herokuapp.com/')
WebUI.delay(1)

TestObject a_MakeAppointment = findTestObject('Page_CURA Healthcare Service_top/a_Make Appointment')
WebUI.verifyElementPresent(a_MakeAppointment, 10)

WebUI.click(a_MakeAppointment)
WebUI.delay(1)

TestObject input_username = findTestObject('Page_CURA Healthcare Service_login/input_Username_username')
WebUI.setText(input_username, 'John Doe')
WebUI.delay(1)

TestObject input_password = findTestObject('Page_CURA Healthcare Service_login/input_Password_password')
WebUI.setEncryptedText(input_password, 'g3/DOGG74jC3Flrr3yH+3D/yKbOqqUNM')
WebUI.delay(1)

TestObject button_Login = findTestObject('Page_CURA Healthcare Service_login/button_Login')
WebUI.click(button_Login)
WebUI.delay(1)

TestObject select_Facility = findTestObject('Page_CURA Healthcare Service_appointment/select_Facility')
WebUI.selectOptionByIndex(select_Facility, 0)
WebUI.delay(1)

TestObject input_hospital_readm = findTestObject('Page_CURA Healthcare Service_appointment/input_Apply for hospital readm')
WebUI.click(input_hospital_readm)
WebUI.delay(1)

TestObject input_Medicaid = findTestObject('Page_CURA Healthcare Service_appointment/input_Medicaid_programs')
WebUI.click(input_Medicaid)
WebUI.delay(1)

TestObject input_Visit_Date = findTestObject('Page_CURA Healthcare Service_appointment/input_Visit Date (Required)_vi')
WebUI.setText(input_Visit_Date, '01/12/34')
WebUI.delay(1)

TestObject textarea_comment = findTestObject('Page_CURA Healthcare Service_appointment/textarea_Comment_comment')
WebUI.setText(textarea_comment, 'This is a comment')
WebUI.delay(1)

TestObject button_Book_Appointment = findTestObject('Page_CURA Healthcare Service_appointment/button_Book Appointment')
WebUI.click(button_Book_Appointment)
WebUI.delay(1)

TestObject a_Go_to_Homepage = findTestObject('Page_CURA Healthcare Service_summary/a_Go to Homepage')
WebUI.click(a_Go_to_Homepage)
WebUI.delay(1)

WebUI.closeBrowser()
79 changes: 47 additions & 32 deletions Scripts/TC1/Script1547070867765.groovy
Original file line number Diff line number Diff line change
@@ -1,65 +1,80 @@
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

/**
* This script visits the page at https://katalon-demo-cura.herokuapp.com/
* and the linked pages while highlighting elements with red border.
* This script repeats explicitly calling a custome keyword to put the highlight
* so that this script looks tedius.
*/




// open browser and navigate to the AUT
WebUI.openBrowser('')
WebUI.setViewPortSize(1024, 768)
WebUI.navigateToUrl('https://katalon-demo-cura.herokuapp.com/')
WebUI.delay(1)

// highlight a specific element
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(
findTestObject('Page_CURA Healthcare Service_top/h1_CURA Healthcare Service'))
WebUI.delay(2)

WebUI.comment("Hello, world")
TestObject a_MakeAppointment = findTestObject('Page_CURA Healthcare Service_top/a_Make Appointment')
WebUI.verifyElementPresent(a_MakeAppointment, 10)

// modify WebUI.* keywords which take TestObject as arg0
// so that they call Highlight.on() automatically
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.pandemic'()

WebUI.click(findTestObject('Page_CURA Healthcare Service_top/a_Make Appointment'))
// highlight the element
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(a_MakeAppointment)
WebUI.click(a_MakeAppointment)
WebUI.delay(1)

WebUI.setText(findTestObject('Page_CURA Healthcare Service_login/input_Username_username'), 'John Doe')
TestObject input_username = findTestObject('Page_CURA Healthcare Service_login/input_Username_username')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(input_username)
WebUI.setText(input_username, 'John Doe')
WebUI.delay(1)

WebUI.setEncryptedText(findTestObject('Page_CURA Healthcare Service_login/input_Password_password'), 'g3/DOGG74jC3Flrr3yH+3D/yKbOqqUNM')
TestObject input_password = findTestObject('Page_CURA Healthcare Service_login/input_Password_password')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(input_password)
WebUI.setEncryptedText(input_password, 'g3/DOGG74jC3Flrr3yH+3D/yKbOqqUNM')
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_login/button_Login'))
TestObject button_Login = findTestObject('Page_CURA Healthcare Service_login/button_Login')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(button_Login)
WebUI.click(button_Login)
WebUI.delay(1)

//WebUI.selectOptionByValue(findTestObject('Page_CURA Healthcare Service_appointment/select_Facility'),
// 'Hongkong CURA Healthcare Center', false)
//WebUI.delay(1)

//WebUI.selectOptionByLabel(findTestObject('Page_CURA Healthcare Service_appointment/select_Facility'),
// 'Seoul CURA Healthcare Center', false)
//WebUI.delay(1)

WebUI.selectOptionByIndex(findTestObject('Page_CURA Healthcare Service_appointment/select_Facility'), 0)
TestObject select_Facility = findTestObject('Page_CURA Healthcare Service_appointment/select_Facility')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(select_Facility)
WebUI.selectOptionByIndex(select_Facility, 0)
WebUI.delay(1)


WebUI.click(findTestObject('Page_CURA Healthcare Service_appointment/input_Apply for hospital readm'))
TestObject input_hospital_readm = findTestObject('Page_CURA Healthcare Service_appointment/input_Apply for hospital readm')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(input_hospital_readm)
WebUI.click(input_hospital_readm)
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_appointment/input_Medicaid_programs'))
TestObject input_Medicaid = findTestObject('Page_CURA Healthcare Service_appointment/input_Medicaid_programs')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(input_Medicaid)
WebUI.click(input_Medicaid)
WebUI.delay(1)

WebUI.setText(findTestObject('Page_CURA Healthcare Service_appointment/input_Visit Date (Required)_vi'), '01/12/34')
TestObject input_Visit_Date = findTestObject('Page_CURA Healthcare Service_appointment/input_Visit Date (Required)_vi')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(input_Visit_Date)
WebUI.setText(input_Visit_Date, '01/12/34')
WebUI.delay(1)

WebUI.setText(findTestObject('Page_CURA Healthcare Service_appointment/textarea_Comment_comment'), 'This is a comment')
TestObject textarea_comment = findTestObject('Page_CURA Healthcare Service_appointment/textarea_Comment_comment')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(textarea_comment)
WebUI.setText(textarea_comment, 'This is a comment')
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_appointment/button_Book Appointment'))
TestObject button_Book_Appointment = findTestObject('Page_CURA Healthcare Service_appointment/button_Book Appointment')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(button_Book_Appointment)
WebUI.click(button_Book_Appointment)
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_summary/a_Go to Homepage'))
TestObject a_Go_to_Homepage = findTestObject('Page_CURA Healthcare Service_summary/a_Go to Homepage')
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(a_Go_to_Homepage)
WebUI.click(a_Go_to_Homepage)
WebUI.delay(1)

WebUI.closeBrowser()
WebUI.closeBrowser()
71 changes: 40 additions & 31 deletions Scripts/TC2/Script1547960621812.groovy
Original file line number Diff line number Diff line change
@@ -1,65 +1,74 @@
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

/**
* This script visits the page at https://katalon-demo-cura.herokuapp.com/
* and the linked pages while highlighting elements with red border.
* This script does the same as the TC1 but is much shorter.
* This script calls the `pandemic` method of the
* `com.kazurayam.ksbackyard.HighlightElement` class,
* which dynamically modifies the `WebUI.setText` and other built-in keywords
* using Groovy's Metaprogramming technique.
*/

// open browser and navigate to the AUT
WebUI.openBrowser('')
WebUI.setViewPortSize(1024, 768)
WebUI.navigateToUrl('https://katalon-demo-cura.herokuapp.com/')
WebUI.delay(1)

// highlight a specific element
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.on'(
findTestObject('Page_CURA Healthcare Service_top/h1_CURA Healthcare Service'))
WebUI.delay(2)



// modify WebUI.* keywords which take TestObject as arg0
// so that they call Highlight.on() automatically
// pandemic() will modify some WebUI.* keywords so that they call
// com.kazurayam.ksbackyard.Highlight.on(testobject)
// automatically
CustomKeywords.'com.kazurayam.ksbackyard.HighlightElement.pandemic'()

WebUI.click(findTestObject('Page_CURA Healthcare Service_top/a_Make Appointment'), FailureHandling.CONTINUE_ON_FAILURE)
WebUI.delay(1)
TestObject a_MakeAppointment = findTestObject('Page_CURA Healthcare Service_top/a_Make Appointment')
WebUI.verifyElementPresent(a_MakeAppointment, 10)

WebUI.setText(findTestObject('Page_CURA Healthcare Service_login/input_Username_username'), 'John Doe', FailureHandling.CONTINUE_ON_FAILURE)
// the target element for WebUI.click keyword will be highlighted
WebUI.click(a_MakeAppointment)
WebUI.delay(1)

WebUI.setEncryptedText(findTestObject('Page_CURA Healthcare Service_login/input_Password_password'), 'g3/DOGG74jC3Flrr3yH+3D/yKbOqqUNM', FailureHandling.CONTINUE_ON_FAILURE)
TestObject input_username = findTestObject('Page_CURA Healthcare Service_login/input_Username_username')
WebUI.setText(input_username, 'John Doe')
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_login/button_Login'), FailureHandling.CONTINUE_ON_FAILURE)
TestObject input_password = findTestObject('Page_CURA Healthcare Service_login/input_Password_password')
WebUI.setEncryptedText(input_password, 'g3/DOGG74jC3Flrr3yH+3D/yKbOqqUNM')
WebUI.delay(1)

//WebUI.selectOptionByValue(findTestObject('Page_CURA Healthcare Service_appointment/select_Facility'),
// 'Hongkong CURA Healthcare Center', false)
//WebUI.delay(1)

//WebUI.selectOptionByLabel(findTestObject('Page_CURA Healthcare Service_appointment/select_Facility'),
// 'Seoul CURA Healthcare Center', false)
//WebUI.delay(1)

WebUI.selectOptionByIndex(findTestObject('Page_CURA Healthcare Service_appointment/select_Facility'), 0, FailureHandling.CONTINUE_ON_FAILURE)
TestObject button_Login = findTestObject('Page_CURA Healthcare Service_login/button_Login')
WebUI.click(button_Login)
WebUI.delay(1)

TestObject select_Facility = findTestObject('Page_CURA Healthcare Service_appointment/select_Facility')
WebUI.selectOptionByIndex(select_Facility, 0)
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_appointment/input_Apply for hospital readm'), FailureHandling.CONTINUE_ON_FAILURE)
TestObject input_hospital_readm = findTestObject('Page_CURA Healthcare Service_appointment/input_Apply for hospital readm')
WebUI.click(input_hospital_readm)
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_appointment/input_Medicaid_programs'), FailureHandling.CONTINUE_ON_FAILURE)
TestObject input_Medicaid = findTestObject('Page_CURA Healthcare Service_appointment/input_Medicaid_programs')
WebUI.click(input_Medicaid)
WebUI.delay(1)

WebUI.setText(findTestObject('Page_CURA Healthcare Service_appointment/input_Visit Date (Required)_vi'), '01/12/34', FailureHandling.CONTINUE_ON_FAILURE)
TestObject input_Visit_Date = findTestObject('Page_CURA Healthcare Service_appointment/input_Visit Date (Required)_vi')
WebUI.setText(input_Visit_Date, '01/12/34')
WebUI.delay(1)

WebUI.setText(findTestObject('Page_CURA Healthcare Service_appointment/textarea_Comment_comment'), 'This is a comment', FailureHandling.CONTINUE_ON_FAILURE)
TestObject textarea_comment = findTestObject('Page_CURA Healthcare Service_appointment/textarea_Comment_comment')
WebUI.setText(textarea_comment, 'This is a comment')
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_appointment/button_Book Appointment'), FailureHandling.CONTINUE_ON_FAILURE)
TestObject button_Book_Appointment = findTestObject('Page_CURA Healthcare Service_appointment/button_Book Appointment')
WebUI.click(button_Book_Appointment)
WebUI.delay(1)

WebUI.click(findTestObject('Page_CURA Healthcare Service_summary/a_Go to Homepage'), FailureHandling.CONTINUE_ON_FAILURE)
TestObject a_Go_to_Homepage = findTestObject('Page_CURA Healthcare Service_summary/a_Go to Homepage')
WebUI.click(a_Go_to_Homepage)
WebUI.delay(1)

WebUI.closeBrowser()
WebUI.closeBrowser()
9 changes: 9 additions & 0 deletions Test Cases/TC0.tc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<TestCaseEntity>
<description></description>
<name>TC0</name>
<tag></tag>
<comment></comment>
<recordOption>OTHER</recordOption>
<testCaseGuid>78b3ca65-5cb5-4a9e-b949-e19dbccff62a</testCaseGuid>
</TestCaseEntity>
1 change: 1 addition & 0 deletions Test Cases/TC1.tc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<name>TC1</name>
<tag></tag>
<comment></comment>
<recordOption>OTHER</recordOption>
<testCaseGuid>d58ff4fd-fb65-4bf0-aa81-58c745a3616b</testCaseGuid>
</TestCaseEntity>
1 change: 1 addition & 0 deletions Test Cases/TC2.tc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<name>TC2</name>
<tag></tag>
<comment></comment>
<recordOption>OTHER</recordOption>
<testCaseGuid>db7cf54b-ae6d-4f6b-924e-1cb8667c0d91</testCaseGuid>
</TestCaseEntity>

0 comments on commit 49d411a

Please sign in to comment.