m de boer
Katalon Apprentice
03/13/2018

conditional statements

Katalon seems to be an easy to use testtool to create aut testscripts very easy. But now and than there is something strange in appearantly simple constructions in the testcases. 
I want to make a conditional step in my case ( if this is true, then do that). It seems that it only works if the condition is indeed true. If the condition is false, then i get the message
statement:
if (!WebUI.verifyElementAttributeValue(findTestObject('InProces/Inproces 2.12-SNAPSHOT/md-switch_afgehandeld'), 'aria-checked', 
    'false', 0)) {
    WebUI.click(findTestObject('InProces/Inproces 2.12-SNAPSHOT/md-switch_afgehandeld'), FailureHandling.CONTINUE_ON_FAILURE)
}

error:
Test Cases/koppel CB in Squit2020 FAILED because (of) Unable to verify if object 'Object Repository/InProces/Inproces 2.12-SNAPSHOT/md-switch_afgehandeld' has attribute 'aria-checked' with value 'false' (Root cause: Object 'Object Repository/InProces/Inproces 2.12-SNAPSHOT/md-switch_afgehandeld' has attribute 'aria-checked' with actual value 'true' instead of expected value 'false')

is this a bug or am I causing this failure? Is there anybody with an idea how to solve this?
Tagged:
Upvote
Quote

Comments

  • Charles Brown
    Katalon Ambassador
    06/15/2018
    I was able to solve this using the FailureHandling.OPTIONAL in my condition.
    Instead of using the "!" I used "== false" in the condition. See the example below:

    if ((WebUI.verifyElementVisible(button_Create, FailureHandling.OPTIONAL)) == false) {
        def Text = WebUI.getText(div_ErrorMessage)
        println(Text)
        return null 
    } else {
    WebUI.click(findTestObject('button_Create'))
    }

    Hope this helps.
    Best Answer
    Upvote
    Quote
  • Joseph
    Katalon Apprentice
    03/14/2018
    edited March 14
    It's not a bug. Katalon really will throw an error if a verify method returns false. I did a quick test on YOPmail.

    Code:
    WebUI.verifyElementAttributeValue(findTestObject('YOPmail - Inbox/txtRecipient'), 'name', 'poi', 0)

    Error:
    Test Cases/Send Mail FAILED because (of) Unable to verify if object 'Object Repository/YOPmail - Inbox/txtRecipient' has attribute 'name' with value 'poi' (Root cause: Object 'Object Repository/YOPmail - Inbox/txtRecipient' has attribute 'name' with actual value 'mailto' instead of expected value 'poi')
    Upvote
    Quote
Sign In or Register to comment.
Not the answer you're looking for? Consider subscribing to Business support.