In a nutshell
Note: Handle Alert has no parameter for entering text into a prompt dialog. Accepting a prompt dialog submits whatever value is already present in its input field.| Parameter | Data Type | Description |
| decision | BOOLEAN | Determines how the task responds to the dialog. Accepted values:
|
| message (Optional) | STRING | The expected text displayed in the dialog. When provided, the task verifies the dialog message before responding and fails if the messages don't match. |
Accept a payment confirmation dialog after confirming it shows the correct order number.
// Click the Make Payment button using the Click task
click("#zs-make-payment-button");
// Wait for the payment to process
wait(5);
// Confirm the payment confirmation dialog's message and accept it using the Handle Alert task
handleAlert(True, "Payment for Order #12345 was successful.");
// Confirm the order confirmation page loads using the Assert Visible task
assertVisible(ui.zwatch.order-confirmation-heading, errorhandling.STOP_ON_ERROR);where:
| #zs-make-payment-button | Locator for the Make Payment button. |
| 5 | Duration to wait for the payment to process, in seconds. |
| True | Accepts the dialog. |
| "Payment for Order #12345 was successful." | Expected message displayed in the payment confirmation dialog. |
| ui.zwatch.order-confirmation-heading | Locator for the order confirmation heading. |
| errorhandling.STOP_ON_ERROR | Stops the test case if the order confirmation heading isn't visible. |
Accept the cart-clearing confirmation dialog and confirm the cart is empty afterward.
// Click the Clear Cart button using the Click task
click("#zs-clear-cart-button");
// Accept the confirmation dialog using the Handle Alert task
handleAlert(True);
// Confirm the cart is empty using the Assert Visible task
assertVisible(ui.zwatch.empty-cart-message, errorhandling.STOP_ON_ERROR);where:
| #zs-clear-cart-button | Locator for the Clear Cart button. |
| True | Accepts the confirmation dialog. |
| ui.zwatch.empty-cart-message | Locator for the empty cart message. |
| errorhandling.STOP_ON_ERROR | Stops the test case if the empty cart message isn't visible. |
Dismiss a delete confirmation dialog and confirm the item still exists afterward.
// Click the Delete button using the Click task
click(ui.<page_name>.<delete_button>);
// Dismiss the confirmation dialog using the Handle Alert task
handleAlert(False);
// Confirm the item still exists using the Assert Visible task
assertVisible(ui.<page_name>.<item>, errorhandling.STOP_ON_ERROR);where:
| ui.<page_name>.<delete_button> | Locator for the Delete button. |
| False | Dismisses the confirmation dialog. |
| ui.<page_name>.<item> | Locator for the item that should still exist after dismissing the dialog. |
| errorhandling.STOP_ON_ERROR | Stops the test case if the item isn't visible. |
Implementation
// Step 1: Open the records page using the Open URL task
openURL("<webpage_url>/records", "same window");
// Step 2: Select the records to delete using the Check task
check(ui.<records_page>.<select_all_checkbox>);
// Step 3: Click the bulk delete button using the Click task
click(ui.<records_page>.<bulk_delete_button>);
// Step 4: Confirm the dialog message and accept it to complete the deletion
handleAlert(True, "Delete 12 selected records?");
// Step 5: Wait until the success message becomes visible
wait(10, ui.<records_page>.<delete_success_message>, event.SHOW);
// Step 6: Confirm the success message text using the Assert Text task
assertText(ui.<records_page>.<delete_success_message>, "12 records deleted", errorhandling.STOP_ON_ERROR);Implementation
// Step 1: Open the profile edit form using the Open URL task
openURL("<webpage_url>/profile/edit", "same window");
// Step 2: Update the display name field using the Set Value task
setValue(ui.<profile_edit_page>.<display_name_field>, "Jordan Lee");
// Step 3: Click the Home navigation link using the Click task
click(ui.<profile_edit_page>.<home_nav_link>);
// Step 4: Confirm the unsaved changes warning and dismiss it to stay on the page
handleAlert(False, "You have unsaved changes. Leave this page?");
// Step 5: Confirm the display name field still holds the entered value using the Assert Value task
assertValue(ui.<profile_edit_page>.<display_name_field>, "Jordan Lee", errorhandling.STOP_ON_ERROR);Users renaming a file in a file manager need the dialog's pre-filled name preserved unless they intentionally change it, so an accidental accept doesn't silently corrupt the file name.
A tester uses Zoho QEngine to confirm that accepting the dialog without changing the pre-filled text keeps the file's name correct in the file list.
Steps
Implementation
// Step 1: Open the file manager page using the Open URL task
openURL("<webpage_url>/files", "same window");
// Step 2: Click the rename button for the target file using the Click task
click(ui.<file_manager_page>.<rename_button>);
// Step 3: Confirm the prompt message and accept it, submitting the pre-filled file name unchanged
handleAlert(True, "Rename this file?");
// Step 4: Wait until the file name label is present again after the rename action completes
wait(10, ui.<file_manager_page>.<file_name_label>, event.PRESENT);
// Step 5: Confirm the file name remains unchanged in the file list using the Assert Text task
assertText(ui.<file_manager_page>.<file_name_label>, "Q3_Report.pdf", errorhandling.STOP_ON_ERROR);Now that you've learned all the Miscellaneous tasks, learn how to perform pointer-based interactions using the tasks in the Keyboard and Mouse Actions group, starting with the <Double Click> task.
Before using the Handle Alert task, ensure that you've learned how to display a debugging message using the Info task.