How can I test a function that contains a "waitFor" function or popup dialogs without requiring external user input?
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Jianfei
el 18 de Nov. de 2024
I am testing a GUI function in my code. Within my test class, I use Java functions to simulate mouse clicks, which trigger a popup dialog. However, the function execution pauses at the waitFor line, requiring me to manually click a button to close the dialog before the code can proceed. How can I automate this process entirely?
1 comentario
Walter Roberson
el 18 de Nov. de 2024
I think I once saw someone simulate pressing buttons through MATLAB Tester... but I cannot seem to find any way to do that at the moment.
Más respuestas (2)
Madheswaran
el 18 de Nov. de 2024
Hi,
Starting from MATLAB R2024b, you can programmatically interact with alert and confirmation dialog boxes using 'chooseDialog' and 'dismissDialog' methods. They work with both modal and non-modal dialogs and can automatically select options or close dialogs without manual intervention.
For more information and examples, refer to the following documentations:
- dismissDialog - https://mathworks.com/help/matlab/ref/matlab.uitest.testcase.dismissdialog.html
- chooseDialog - https://mathworks.com/help/matlab/ref/matlab.uitest.testcase.choosedialog.html
Hope this helps!
1 comentario
Walter Roberson
el 18 de Nov. de 2024
Unfortunately the user is using R2023b. But perhaps they will be willing to upgrade.
埃博拉酱
el 18 de Nov. de 2024
Possible ideas:
- Create a waitfor function for testing in the current directory before testing to see if it can mask the waitfor of MATLAB.
- Create an environment or a global variable with a special name (such as YourAppName_Debug) before the test, check whether the environment variable exists in the test objective function, and skip the dialog box if it exists.
- Add an undocumented optional parameter to the function. This parameter is only offered by the developer in the test environment.
0 comentarios
Ver también
Categorías
Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!