In this katalon studio tutorial, we are going to perform automation test using script mode in katalon studio. Create a test case using the script in katalon studio.
Let’s assume we have a simple test case with following steps:
- Open the browser.
- Navigate to the website or a page.
- Verify A text on the web page.
- Click on the element.
- Verify the element.
- Close browser.
Create a test case using script mode in katalon studio
Step1: Right Click on the test case and create a new test case. Enter the name of the test case and the description of the test case. And Click OK.
Step2: Click on the script tab.
Step3: Just copy the code and run your script.
import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase import static com.kms.katalon.core.testdata.TestDataFactory.findTestData import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile import com.kms.katalon.core.model.FailureHandling as FailureHandling import com.kms.katalon.core.testcase.TestCase as TestCase import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory import com.kms.katalon.core.testdata.TestData as TestData import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository import com.kms.katalon.core.testobject.TestObject as TestObject import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI import internal.GlobalVariable as GlobalVariable WebUI.openBrowser('') WebUI.navigateToUrl('https://demoaut.katalon.com/') WebUI.verifyElementPresent(findTestObject('DemoObjectRepository/Page_CURA Healthcare Service/a_Make Appointment'), 20) WebUI.verifyTextPresent('CURA Healthcare Service', false) WebUI.click(findTestObject('DemoObjectRepository/Page_CURA Healthcare Service/a_Make Appointment')) WebUI.closeBrowser()
Srcipt mode in katalon studio Code Explaination
WebUI.openBrowser(”)
//To open a browser.
WebUI.navigateToUrl(‘http://demoaut.katalon.com/’)
//To navigate on a link.
WebUI.verifyElementPresent(findTestObject(‘DemoObjectRepository/Page_CURA Healthcare Service/a_Make Appointment’), 20)
//To verify the element “a_Make Appointment” is present or not on the page.
WebUI.verifyTextPresent(‘CURA Healthcare Service’, false)
//To verify the Text“CURA Healthcare Service” is present or not on the page.
WebUI.click(findTestObject(‘DemoObjectRepository/Page_CURA Healthcare Service/a_Make Appointment’))
//To click on the element “a_Make Appointment”.
WebUI.closeBrowser()
//To close the Browser.