How to Handle Check box

How to Handle These Check Box
example :

Select : if it is already marked check and don’t click
if it is not check and Click on this

You can do a comparison if the element is checked, or not. If element is not checked, check it.

if (WebUI.verifyElementNotChecked(findTestObject(...pathway to Select), 10)) { 
    WebUI.check(findTestObject(...pathway to Select))
}

or

if (!WebUI.verifyElementChecked(findTestObject(...pathway to Select), 10)) { 
    WebUI.check(findTestObject(...pathway to Select))
}

Edit: You can make a Keyword of the statement and pass in your Test Object.

CustomKeywords.‘com.Tools.verifyChecked’(findTestObject(…pathway to Select))
CustomKeywords.‘com.Tools.verifyChecked’(findTestObject(…pathway to Create))
CustomKeywords.‘com.Tools.verifyChecked’(findTestObject(…pathway to Email))

/**
* If it is already marked check and don’t click
* if it is not check and Click on this
* @param Katalon test object 
*/
@Keyword
public void verifyChecked(TestObject obj) {

    if (WebUI.verifyElementNotChecked(obj, 10)) { 
        WebUI.check(obj)
    }
}
2 Likes

If you work only on the Manual page, then I’m not able to assist you much at all. I work on the Script page, so:

  1. if you copy and paste the above if statement to the Script page, and
  2. then Drag and Drop the checkbox’s findTestObject for the Select checkbox from the Object Repository onto the Script page,
  3. then cut the checkbox’s findTestObject from where you dragged it to onto the Script page and paste it over the section of code to replace the artifact that I used, you should be able to test the first item.

After that, repeat the above for all the other checkbox items.

As for the Keyword, there is a document Katalon has that you should review first.

Introduction to custom keywords in Katalon Studio | Katalon Docs

Edit: I will give you a warning that you should NOT make changes and MOVE between the Script page and the Manual page. Save any changes before you move between the Script page and the Manual page. Even then your code may become corrupted. Katalon knows about this issue, but it has not been resolved.
Edit2: If you try to do this on the Manual tab, then the if statement would be called a Decision-making Statement > if statement

1 Like

Hi @noor.ahmed, we noticed that you have been asking quite a few questions up till now. We just want to check in to see if you have found the solution that you need?

If yes, then don’t forget to mark helpful replies as a solution :white_check_mark: so that others who may be asking similar questions / running into similar problems can find the solution as well!

Thanks! :sunglasses:


We actually would encourage you to keep discussing with other members on our forum until you get the solution(s) that you need. That way, other members who may have the same issues can find the solution here to. Thanks :+1: