Sometimes it is possible that additional windows and dialogs that did not appear during recording appear during replay. For example, a multiple user login alert displays when logging in with the same user multiple times.
To create an error-free script, it is necessary to check whether a new window is available before scripting such functions as SapGuiSetActiveWindow, otherwise an error will occur.
if(SapGuiVerifyWindowAvailability("wnd[1]", null, false, SEVERITY_INFORMATIONAL)) then SapGuiSetActiveWindow("wnd[1]"); SapGuiSelectRadioButton(""); SapGuiPressButton(""); end;
SapGuiVerifyObjectAvailability(gsConnId + "/ses[0]/ wnd[1]", true, SEVERITY_INFORMATIONAL)
The reason we use SEVERITY_INFORMATIONAL is that we do not want to receive an error if the object/window is not present, we only want to perform an action if the object is there. No error should be logged if the object is not there.
SapGuiVerifyWindowAvailability has an additional parameter with which the window title can be verified. This can be useful when you expect one of multiple possible dialogs where the user can proceed in one of several ways. The function can be used to simply verify if a dialog with a certain title is available.