Unable to click a check box

I am unable to make the script click the check box, I had tried 3 ways.

I do something like this:
//Scroll to element

WebUI.scrollToElement(findTestObject(‘Object Repository/100/Page_Review your order/input_Rules of purchase-sale of goods at IKEA online store_btnreview’), 3)
WebUI.delay(1)

//click the element.
WebUI.click(findTestObject(‘Object Repository/100/Page_Review your order/label_Ive read and understood Rules of purchase-sale of goods at IKEA online store’))

//I also tried with check
WebUI.check(findTestObject(‘Object Repository/100/Page_Review your order/input_Rules of purchase-sale of goods at IKEA online store_btnreview’))

//and with a off set
//WebUI.clickOffset(findTestObject(‘Object Repository/100/Page_Review your order/input_Rules of purchase-sale of goods at IKEA online store_btnreview’), 863, 1243)

But the checkbox do not want to be marked. I got the commands with the record web button, and put the

Can you share a screenshot of the “label_Ive read and understood Rules of purchase-sale of goods at IKEA online store” Test Object?

try to add and element manually in the object repository
name it “checkbox_iHaveRead”
select xpath option and paste there the xpath: //*[@id=‘checktermscond’]
save the element
then try to click on the element saved “checkbox_iHaveRead”

Of course,
This is the code inside: /Object Repository/100/Page_Review your order/label_Ive read and understood Rules of purchase-sale of goods at IKEA online store . This was done with the record function of Katalon.

The large line that you can not see on the image:
id("checkout")/div[@class="row justify-content-center"]/div[@class="review_section col-12 col-lg-6 offset-lg-1"]/div[@class="terms-conditions_section"]/div[@class="checkbox m-0 my-0"]/label[@class="text"]

Something like this:

WebUI.selectOptionByLabel(findTestObject(‘checkbox_iHaveRead’), ‘’, true)

error-006

I changed to this:
…XPATH
//*[@id=‘checktermscond’]

Test Cases/Buy-003 FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to check object ‘Object Repository/checkbox_iHaveRead’
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.CheckKeyword.check(CheckKeyword.groovy:88)
at com.kms.katalon.core.webui.keyword.builtin.CheckKeyword.execute(CheckKeyword.groovy:67)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.check(WebUiBuiltInKeywords.groovy:1039)

I think WebUI.selectOptionByLabel is for dropdown list and not checkbox.

Yes, i have tried also with manually element like @ francorebu recomend.
WebUI.check(findTestObject(‘checkbox_iHaveRead’))
WebUI.click(findTestObject(‘checkbox_iHaveRead’))

But do not want to work…

@Richard.QA : I have the same problem , unable to click or check the checkbox in Katalon , is your problem solved ? if you have the solution please let me know.

My problem got resolved. By using custom keyword java script method click , I can able to click the check box.
Thanks .

Can you share it?

@shanu : can you share the proper solution.

Under “Keywords” section - Create a file name with commonkeywords and use the below method

public class CommonKeywords {
/**
* Click Web element
*/
@Keyword
def clickUsingJS(TestObject to) {
WebDriver driver = DriverFactory.getWebDriver()
WebElement element = WebUiCommonHelper.findWebElement(to,30)
JavascriptExecutor executor = ((driver) as JavascriptExecutor)
executor.executeScript(‘arguments[0].click()’, element)
}
}

In the testcase file, call the method like below:

CustomKeywords.‘custom_InvestX.CommonKeywords.clickUsingJS’(findTestObject(‘Web_Login_Objects/Chkbox_I_have_read_the_privacy_policy’))

Java script executor demo in Katalon studio


Check box automation in Katalon studio
1 Like