Main Content

dismissAlertDialog

Class: matlab.uitest.TestCase
Namespace: matlab.uitest

(Not recommended) Close frontmost alert dialog box in figure window

Since R2021a

dismissAlertDialog is not recommended. Use dismissDialog instead. For information on updating your code, see Version History.

Description

dismissAlertDialog(testCase,fig) closes the frontmost alert dialog box in the specified figure window.

example

Input Arguments

expand all

Test case, specified as a matlab.uitest.TestCase object.

Target figure, specified as a matlab.ui.Figure object. The figure must be created with the uifigure function.

Attributes

Sealedtrue

To learn about attributes of methods, see Method Attributes.

Examples

expand all

Create a modal alert dialog box. The figure behind the dialog box is inaccessible until you close the dialog box.

fig = uifigure;
uialert(fig,"File not found","Invalid File")

A figure window behind an alert dialog box

Create an interactive test case and close the alert dialog box. The dialog box disappears, and the figure behind it is accessible again.

testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.dismissAlertDialog(fig)

A figure window after closing the alert dialog box

Version History

Introduced in R2021a

collapse all

R2024b: Not recommended

dismissAlertDialog is not recommended. Use dismissDialog instead. There are no plans to remove dismissAlertDialog. However, the dismissDialog method provides more functionality and is not limited to alert dialog boxes. For example, you can use the dismissDialog method to close an alert dialog box or a confirmation dialog box.

This table shows how to update your code to use dismissDialog instead.

Not RecommendedRecommended
fig = uifigure;
uialert(fig,"File not found","Invalid File")

testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.dismissAlertDialog(fig)
fig = uifigure;
uialert(fig,"File not found","Invalid File")

testCase = matlab.uitest.TestCase.forInteractiveUse;
testCase.dismissDialog("uialert",fig)