Script failing in overall status

Hi Katalon experts,

I have the below script with an if condition that fails (overall status) when the else if is executed but all the steps finish fine


import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

WebUI.openBrowser('')

WebUI.navigateToUrl('https://company.portal.com/saml_login?ReturnTo=https%3A//company.portal.com/')

WebUI.setText(findTestObject('Page_Company - Sign In/input_Username_username'), 'user1')

WebUI.setEncryptedText(findTestObject('Page_company - Sign In/input_Password_password'), 'pw1')

WebUI.click(findTestObject('Page_Company - Sign In/input_Remember me_okta-signin-submit'))

WebUI.scrollToElement(findTestObject('Page_Home page  portal/div_Switch to 24hr'), 0)

WebUI.click(findTestObject('Page_Home page  portal/div_Switch to 24hr'))

WebUI.verifyElementPresent(findTestObject('Object Repository/Page_Home page  portal/ul_clock section'), 0)

WebUI.verifyElementVisible(findTestObject('Page_Home page  portal/ul_clock section'))

CustomKeywords.'ClickJS.clickUsingJS'(findTestObject('Page_Home page  portal/span_Personalize Clocks'), 30)

if (WebUI.verifyElementChecked(findTestObject('Object Repository/Page_Personalized Clocks  portal/input_Update this item_taxonomy_term_bulk_form8'), 
    0)) {
    WebUI.uncheck(findTestObject('Page_Personalized Clocks  portal/input_Update this item_taxonomy_term_bulk_form8'))

    WebUI.check(findTestObject('Object Repository/Page_Personalized Clocks  portal/input_Update this item_taxonomy_term_bulk_form13'))

    WebUI.click(findTestObject('Page_Personalized Clocks  portal/input_West Coast N America_op'))

    WebUI.verifyElementPresent(findTestObject('Object Repository/Page_Home page  portal/span_West Coast N America'), 0)

    WebUI.verifyElementVisible(findTestObject('Page_Home page  portal/span_West Coast N America'))

    WebUI.closeBrowser()
} else if (WebUI.verifyElementChecked(findTestObject('Page_Personalized Clocks  portal/input_Update this item_taxonomy_term_bulk_form13'), 
    0)) {
    WebUI.uncheck(findTestObject('Page_Personalized Clocks  portal/input_Update this item_taxonomy_term_bulk_form13'))

    WebUI.check(findTestObject('Page_Personalized Clocks  portal/input_Update this item_taxonomy_term_bulk_form8'))

    WebUI.click(findTestObject('Page_Personalized Clocks  portal/input_West Coast N America_op'))

    WebUI.verifyElementPresent(findTestObject('Object Repository/Page_Home page  portal/span_East Coast N America'), 0)

    WebUI.verifyElementVisible(findTestObject('Page_Home page  portal/span_East Coast N America'))

    WebUI.closeBrowser()
}

Any idea?

Thanks,
Ruben B

@jpereyra The console log says it failed because the of this line

WebUI.check(findTestObject('Page_Personalized Clocks  portal/input_Update this item_taxonomy_term_bulk_form8'))

WebUI.Check is basically toggling the checkbox or a radio button. I believe it will check a box if it is not checked before Script comes to this step or it will uncheck the box if the box is checked before Script comes to this step.

Can you please explain more here what are you trying to accomplish in this test ?

Hi @manpreet.mukkar,

But it’s weird because all the steps finish fine.

We have a clock section in our portal showing the time for different timezones and it is customizable. The script is to validate that is we make any change, the correct clock is reflected.

it validates if the object “input_Update this item_taxonomy_term_bulk_form8” is checked, if yes, it proceed to uncheck it, then check the object “input_Update this item_taxonomy_term_bulk_form13”, then save the changes and validate that the correct clock is showing up and close the browser. then there is the “else if” that validates if the object “input_Update this item_taxonomy_term_bulk_form13” is checked, if yes, it proceed to uncheck it, then check the object “input_Update this item_taxonomy_term_bulk_form8”, save the changes and validate that the clock is showing up.



Привет, у меня в тест кейсе на 13 шаге
выдает ошибку, можете подсказать
где я допустил ошибку выделил красным где выдает ошибку
image|644x500

Use english please

Hi, I have a 13-speed case in my test
Gives an error, you can tell
Where I made a mistake highlighted in red

Are both the IF and else IF statements true?

Hi @hpulsford,

Yes, it is IF - else IF

if (WebUI.verifyElementChecked(findTestObject('Object Repository/Page_Personalized Clocks  Insider/input_Update this item_taxonomy_term_bulk_form8'), 
    0)) {
    WebUI.uncheck(findTestObject('Page_Personalized Clocks  Insider/input_Update this item_taxonomy_term_bulk_form8'))

    WebUI.check(findTestObject('Object Repository/Page_Personalized Clocks  Insider/input_Update this item_taxonomy_term_bulk_form13'))

    WebUI.click(findTestObject('Page_Personalized Clocks  Insider/input_West Coast N America_op'))

    WebUI.verifyElementPresent(findTestObject('Object Repository/Page_Home page  Insider/span_West Coast N America'), 0)

    WebUI.verifyElementVisible(findTestObject('Page_Home page  Insider/span_West Coast N America'))

    WebUI.closeBrowser()
} else if (WebUI.verifyElementChecked(findTestObject('Page_Personalized Clocks  Insider/input_Update this item_taxonomy_term_bulk_form13'), 
    0)) {
    WebUI.uncheck(findTestObject('Page_Personalized Clocks  Insider/input_Update this item_taxonomy_term_bulk_form13'))

    WebUI.check(findTestObject('Page_Personalized Clocks  Insider/input_Update this item_taxonomy_term_bulk_form8'))

    WebUI.click(findTestObject('Page_Personalized Clocks  Insider/input_West Coast N America_op'))

    WebUI.verifyElementPresent(findTestObject('Object Repository/Page_Home page  Insider/span_East Coast N America'), 0)

    WebUI.verifyElementVisible(findTestObject('Page_Home page  Insider/span_East Coast N America'))

    WebUI.closeBrowser()
}

Thanks,
Ruben B

For the first IF statement, set the Failure handling to Optional. If its set to optional it will not show the test overall as failed, just show a warning for the step that did fail.

Hi @hpulsford,

Thanks for the info, but it seems to be only a workaround. I was wondering if anything is not correct in my code that is causing that failure.

Thanks,
Ruben B