Return a value to be used in IF statement

Hey Everyone,

I’m wondering if there is a way to perform a check on if a value appears in a drop down list and if it doesn’t then return a “False” that I could use in a IF statement to go down a different path to create the value?

I know a few places I could use this in my test as there are some actions that only need to be done the first time then not performed again. It will make my test more robust after a data refresh as an example I wont need to create data manually.

I imagine its been covered elsewhere so happy to just be pointed in the right direction.

Thanks :slight_smile:

Yes. In the docs. Start here:

https://docs.katalon.com/katalon-studio/docs/webui-verify-option-present-by-label.html

WARNING: If your dropdown is not a SELECT element containing OPTION elements, you’ll need to use something else.

1 Like

Hey Russ,

Thanks for the quick reply. I was able to get the check to either pass or fail now which is what I wanted but how do I use the Boolean output from this in one of my IF statements? Do I need to write it to a parameter and if so I don’t suppose you have another handy link?

Sorry if I’m asking basic questions.

Thanks

Hey,

I think I figured it out in script mode, I need to run now but will play with it more tomorrow.

if (WebUI.verifyOptionPresentByValue(findTestObject('CRM/Page_Opportunity Opportunity New Opportunity - Microsoft Dynamics 365/select_--OpSummary-- PrimaryProduct'), 
    '518290005', false, 5)) {
    WebUI.delay(2)

    WebUI.mouseOver(findTestObject('CRM/Page_Opportunity Opportunity New Opportunity - Microsoft Dynamics 365/input_Customer Account_Selection_v1'))

    WebUI.click(findTestObject('CRM/Page_Opportunity Opportunity New Opportunity - Microsoft Dynamics 365/label_Select_Customer_Account_First'))

    WebUI.selectOptionByValue(findTestObject('CRM/Page_Opportunity Opportunity New Opportunity - Microsoft Dynamics 365/select_--OpSummary-- PrimaryProduct'), 
        '518290005', true)
} else { WebUI.setText(findTestObject('CRM/Page_Opportunity Opportunity New Opportunity - Microsoft Dynamics 365/input_Estimated Close Date_v1'), 
    '10/09/2019')
}

Thanks for the help :slight_smile:

1 Like