New to Telerik Test Studio? Download free 30-day trial

How to Handle Dialogs and Popups Generated from the Tested Page

Test Studio recording process recognizes the different dialogs generated from the automated page and detects what actions are taken to handle the dialog. These actions are represented as a single step in the test.

In this article you can find out more about dialog handling in Test Studio tests divided in few sections:

How to Record a Dialog Displayed from the Tested Page

All sample pages used in this article are from the W3School platform.

Dialogs are automatically recorded in Test Studio test taking your actions as baseline. There is a dedicated step for each different dialog with various properties related to the specifics of the dialog - for example, download/upload file path or text, username, etc. When the tested page prompts any dialog, handle it as you would do without Test Studio and Test Studio recorder will add the step for you.

Tip

If you experience any troubles with recording or executing the dialog steps, check if there is an available update in the Latest Browser Support section and apply it before you proceed.

Alert, Confirm, Prompt Dialog Boxes

JavaScript generates three type of popup messages and these are as follows:

  • Alert - often used if some information is to be shared to the user. To proceed the user needs to click 'OK'.
  • Confirm - often used when the user needs to verify or accept something. The user needs to click either "OK" or "Cancel" to proceed.
  • Prompt - often used if the user should submit a value before entering a page. The user needs to click either "OK" or "Cancel" to proceed after entering the input value.

To try out these types of dialogs you can use the 'Try It Yourself' buttons on each example for the W3School JavaScript Popup Boxes page. Here are the steps recorded in a test for each of the dialog boxes.

Alert dialog
Handle Alert Dialog

Confirm dialog
Handle Confirm Dialog

Prompt dialog
Handle Prompt Dialog

Tip

When handling such type of a dialog, usually there is something changed on the page (or remains unchanged depending on the scenario). You can use a verification step to check if the expected outcome after handling the dialog is present.

Logon Dialog

This is an authorization dialog, which requires the user to enter username and password in order to access the requested page. If the logon dialog is canceled or the entered credentials are incorrect, the page returns some sort of an error that the request is not authorized.

Due to the specifics of this dialog and the Test Studio recording process flow, this dialog requires some additional actions to be recorded. These are listed step by step in the below list:

  1. Start the recording session and navigate to the page.
  2. The page is not fully loaded until the logon dialog is handled. Thus the Test Studio recorder is not yet started and attached to the browser. Therefore, if you enter any username and password, these does not get recorded in the Test Studio test.
  3. One option is to enter the valid credentials to login to the page and then manually insert the step to handle the Logon dialog.
  4. The other option is to first cancel the logon dialog - there is no step added in the test because the recorder is not yet active. Once the page returns the message that access is denied, the Test Studio recorder gets attached to the browser. On manually refreshing the page from the browser, the logon dialog prompts again and this time, while you enter your credentials to access the page, Test Studio records your actions and adds the step in the test.

Logon dialog
Handle Logon Dialog

Download and Upload File Dialogs

The Upload dialog brings up the File Explorer window and let's you choose a file from the local disc to upload to the tested server.

Upload dialog
Handle Upload Dialog

The Download dialog is typically a sequence of dialogs - the browser prompts to download a file and the File Explorer lets you choose the destination path. Although the 'Save As' option for the download procedure in the browsers differs, Test Studio recognizes this and records a single Handle Download dialog step. This step covers the complete sequence of dialogs for each browser including the prompt message that the file already exists in the destination folder - the file is overwritten.

Download dialog
Handle Download Dialog

Tip

Part of the browsers calibration settings is to disable the automatic download of files. Thus, if calibrated, the browser always asks where to save the file. In case you don't see the option to choose the destination folder where to save the file, ensure the browser is calibrated and re-record the test scenario.

How to Handle a Popup Page Opened in New Tab

The HTML popup windows or tabs are automatically detected by Test Studio. Depending on the browser these will be open either in a new window (IE), or a new tab (Chrome, Edge, Firefox). In the case when this is a new window, a new Test Studio recorder toolbar is initiated for the new window. In the case when the new page is opened in new tab, Test Studio recorder focus is switched to this new tab until it gets closed.

When recording such scenario Test Studio recorder automatically adds a 'Connect to popup' step when this is detected, then fetches the actions performed in the new window/tab, and once this gets closed, Test Studio adds a 'Close popup' step.

Connect to popup step

Test Studio uses the URL of the new window/tab to connect to it. If the URL is randomly generated, you can use only part of it by enabling the checkbox 'IsUrlPartial'.

Note

Keeping the two windows/tabs opened and switching multiple times between these is not a supported scenario.

Maintain the Handle Dialog and Popup Steps

Test Studio predefined step properties for handling dialog and popus are meant to cover common scenarios without any further adjustments. However, you might face any sort of specific case for which you need to fine tune the default step properties. Find out more about these in the below links:

In this article