Historically, automation of pop-up windows was split into two code areas. The part that triggered the pop-up was written in the main script flow, and a different script flow had to be written to listen to the open popup window occurred event, and to handle the event execution.
The HandlePopup API incorporates the pop-up automation script into the main project code. The API is intended for use on modal pop-up windows only.
public bool HandlePopup<T>(Action action, Action<T> handler, TimeSpan timeout) where T : Window |
Parameter |
Description |
---|---|
action |
The function that opens the pop-up. |
handler |
The action that handles the pop-up, and then closes it. |
timeout |
The period of time within which the action and the handler need to be executed. You may specify the time units of your choice. |
If an error occurs during execution, and/or the timeout period elapses, the method returns False.
If the popup involved is a modal dialog and the handler does not close the window, JIA automatically closes the window, the method returns False, and the appropriate error is recorded in the log.
The following example is based on the SwingSet2 application that is delivered with the JDK of Java versions 1.5 and 1.6. The action is selecting the About menu to open the About window, and the handler is clicking the OK button to close the About window. The window needs to be opened and closed within 10 seconds.
bool b = swingSetMainWindow.HandlePopup<SwingSetMainWindow_AboutSwingJavaWindow>(() => swingSetMainWindow.FileJavaMenu.About.Pick(), aboutWindow => aboutWindow.OKJavaButton.Click(), TimeSpan.FromSeconds(10)); |