lundi 24 décembre 2018

Configuring If-else Statement in Katalon Studio

I'm trying to configure if-else statement, but my code stucks on if statement and doesnt go on else statement.

I've tried to make break; in if statement but it doenst works too

WebUI.openBrowser('')

WebUI.navigateToUrl('123/account/login?ReturnUrl=%2F')

WebUI.maximizeWindow()

WebUI.setText(findTestObject('123/Page_Log in/input_ _Username'), 'admin')

WebUI.setEncryptedText(findTestObject('123/Page_Log in/input_ _Password'), 'admin')

not_run: WebUI.verifyElementPresent(findTestObject('123/Page_Log in/span_Log in'), 1)

WebUI.click(findTestObject('123/Page_Log in/span_Log in'))

not_run: WebUI.verifyElementPresent(findTestObject('123/Page_Operator/button_To activate session sta'), 1)

WebUI.click(findTestObject('123/Page_Operator/button_To activate session sta'))

if (WebUI.verifyTextPresent("Operator already has active session", true)) {
    WebUI.click(findTestObject('if-else/Page_Operator/button_Clear'))

    WebUI.click(findTestObject('if-else/Page_Operator/button_To activate session sta'))

    WebUI.waitForPageLoad(5)

    WebUI.click(findTestObject('123/Page_Operator/click_phone'))

    WebDriver driver = DriverFactory.getWebDriver()

    WebElement Table = driver.findElement(By.xpath('//div[@id=\'missedCallsContainer\']'))

    List<WebElement> rows_table = Table.findElements(By.xpath('//tr[@class=\'dl-menu\']'))

    int rows_count = rows_table.size()

    println('No. of rows: ' + rows_count)
} 

else {
    WebUI.click(findTestObject('123/Page_Operator/click_phone'))
}

it works if the code goes in If statement but if that text what i have provided in if statement doesnt present, it stops working and doesnt go to else.

Aucun commentaire:

Enregistrer un commentaire