I just wanted to know how to create a certain record and after creating this record I want to save it in a certain place and then calling this record in a function and delete that record.
I just want to have a stable delete function cause If I deleted a certain record it won’t be called next time I try to run this delete test script
What do you mean by the word “certain record” here?
Is it a <tr> element in a <table>?
hi @ahmed2
Your test should be include the hook like After Test to delete the created record.
It’s like the teardown step that always executed in the end of your test.
So there’s no issue if your test data is not unique since everytime the data created it’s always deleted on the end of the test.
Is there a certain function that I use please illustrate more
hi @ahmed2
something like:
/
* Executes after every test case ends.
* @param testCaseContext related information of the executed test case.
*/
@AfterTestCase
def sampleAfterTestCase(TestCaseContext testCaseContext) {
//put your test to delete the created data here
//so it will clean your created test data before
}
here is the full details : Test Fixtures and Test Listeners (Test Hooks) in Katalon Studio | Katalon Docs
If you right click on the row, or click on the 3 dots at the end, does a “Delete” menu option appear? If it does, then use that to delete your “test” data.
myItem = createTestObject('//div[@class="scroll-area scroll-content"][1]/div[1]/span[1]/label')
WebUI.waitForElementVisible(myItem, 10)
if (WebUI.verifyMatch(WebUI.getText(myItem), "${gRefName1}", false)) {
WebUI.rightClick(myItem)
WebUI.waitForPageLoad(10)
WebUI.waitForElementVisible(findTestObject('myPage/a_Delete'), 10)
WebUI.verifyElementVisible(findTestObject('myPage/a_Delete'))
WebUI.click(findTestObject('myPage/a_Delete'))
WebUI.waitForPageLoad(10)
"confirm to delete item"
WebUI.waitForElementVisible(findTestObject('myPage/button_Yes'), 10)
WebUI.verifyElementVisible(findTestObject('myPage/button_No'))
WebUI.verifyElementVisible(findTestObject('myPage/button_Yes'))
WebUI.click(findTestObject('myPage/button_Yes'))
WebUI.waitForPageLoad(10)
//WebUI.delay(10)
WebUI.switchToDefaultContent()
}
After further search and using try and error methodology I happy to share that I have found a solution for it as follow :
I have added both create test case and delete test case as a one test case with a global variable that save the record every time I run the create testcase and after that being called in the delete part of the test case so that I use the recent created record to be deleted.
thanks
