depending on the environment, there are different buttons present. If in dev or dev2 then button A is present, if in staging or prod, button B is present. I wrote an if else statement, and it’s not working. Suggestions/help needed pls.
The issue I’m having specifically is if ((internal.GlobalVariable == 'Dev') || (internal.GlobalVariable == 'Dev2')) is not recognized - how do I reference the top level Global Variable, ie Dev, Dev2
if (internal.GlobalVariable == 'Dev' || internal.GlobalVariable == 'Dev2'){
WebUI.click(findTestObject('Page_TESTPartner Test - Services/a_webapp Guest Admin'))
} else if (internal.GlobalVariable == Staging) {
WebUI.click(findTestObject('Supportal/Page_Partner Test - Services/a_webapp Guest Admin_btn btn-default dropdown-toggle'))
WebUI.click(findTestObject('Supportal/Page_Partner Test - Services/a_webapp (Staging)'))
} else if (internal.GlobalVariable == Prod || internal.GlobalVariable == Prod2){
WebUI.click(findTestObject('Supportal/Page_Partner Test - Services/a_webapp Guest Admin_btn btn-default dropdown-toggle'))
WebUI.click(findTestObject('Supportal/Page_Partner Test - Services/a_webapp (Production)'))
}
You don’t normally need to say internal.GlobalVariable - if you have import internal.GlobalVariable at the top of your script, just use GlobalVariable.whatever.
What does that mean? Is there an error? What does it say?
Going by the code you presented, it looks like you are.
Where exactly? I don’t see you doing that in the code.
Aside: You can make your own files (text, json, whatever) and read them at startup. That would provide a way to control the presence of differences not afforded by Katalon profiles. I do this - some of the values I read in are copied over the values in my profiles. Also, a different system could write to those files, too.
I don’t think you can set the Profile programmatically at runtime. Looking at the RunConfiguration documentation, only a get() method is provided, but no set() method.
On a side note, why would an application have different buttons available depending on which environment it’s deployed to? Seems strange… I would also bet that you could come up with a locator that could identify the button you want to click regardless of which environment (which profile) you are executing against.
Can you share any more info on what you are trying to do? Screenshots of the GUI as well as the HTML for the buttons you are working with would help.
Wait so it sounds like no matter which environment, there will always be some button, but the button just has different attributes. If this is the case, the simplest and best solution would be to just create a custom locator for the button that identifies it regardless of the environment. Then you could do away with all of the messy if/else logic and just click it…