Do we have any default method called Executetestcase to call in if condition?

Hello Friends

I have Action button in my application. User will see Edit, View & Delete upon clicking Action button and only if they have grants. created separate test cases for all 3 functionalities. Now I wanted to create a separate test case where i can call and execute only available functionality.
EG: if user dont have Delete permission then script should execute Edit & View only, Delete test case should be ignored.
Do we have any default executetestcase method to call in if condition? if not please share your ideas.

Thanks in Advance

Hi @usekatalon, Hope I am able to understand your situation as above screenshot. You are able to do it by Katalon.

  1. Imaging that button View, Edit are visible/present on page, Delete button is NOT visible/disable/not present
  2. Identify those button by a general formula of Xpath to capture all of them (example: //button[…]
  3. Use Katalon to get all button in the page, foreach button, get its attribute to identify button is present on the page or not
  4. If return true, go with your purposes

Base on that idea, we are able to use Katalon with different ways:

  1. Create CustomKeyword + a little bit about selenium to find object, get attribute and compare attribute with loop (as above comment): Call CustomKeyword in your test script
  2. Create CustomKeyword with parameter is the list of Buttons that you want to test (example, View, Edit, Delete). Capture xpath like: //button[normalize-space(@name = $‘buttonName’)]. For this case, buttonName is a name of button when calling this keyword in loop statement (and $ to get its value), like this:

buttonName: View -> //button[normalize-space(@name = $‘buttonName’] -> //button[normalize-space(@name =‘View’]
Same for others, we have //button[normalize-space(@name =‘Edit’], //button[normalize-space(@name =‘Delete’]

After that, in a loop, get attribute of those button to know it is present in the page or not -> then go with your test case

  1. Another way, you are able to write directly in your test script (test case NOT customized keyword) with above idea instead of using keyword

Hope it is useful for you.

Whether you call a Keyword or a TestCase is up to you but both are available. You just need to organize your IF statement or CASE block to allow the method you choose to perform.

e.g.

if (hasDelete) {
    WebUI.callTestCase(findTestCase('Miscellaneous/removeBook'), [('Title') : 'Blue Moon', ('AuthorKey') : 'Lee Child'], FailureHandling.OPTIONAL)
    WebUI.delay(1)
}

or

if (hasDelete) {
   CustomKeywords.'jabs.Books.removeAuthor'('Dr. Seuss')
   WebUI.delay(1)
}

sorry for the late response and used calltestcase.

Thanks alot NGUYEN :slight_smile:

sorry for the late response and used calltestcase.

Thanks alot GRYLION :slight_smile: