So I'm learning how to use TC10 and doing some experimentation with writing my own scripts to find out what I can do. I've come across an issue handling sort-of-unexpected (but not entirely unexpected!) dialog boxes appearing. By recording scripts I have acquired TC script code that does the job but I wanted to know if I was doing this right.
I'm testing a Windows Desktop app and my example scenario is a File/SaveAs operation. If the save as filename already exists you get a prompt asking if you want to overwrite it. So the first run the save-as filename won't exist and hence no prompt will appear, but might thereafter. So I want to handle the prompt dialog appearing or not for a robust test.
I can test for this alert thus and press Yes to confirm the overwrite:
if (myApp.dlgConfirmSaveAs.Exists)
myApp.dlgConfirmSaveAs.Confirm_Save_As.CtrlNotifySink.btnYes.ClickButton();
But this results in a noticable delay while the tell-tale indicator says it's waiting a few seconds for dlgConfirmSaveAs.
I have found that I can also do this:
if (Sys.Process("MyApp").WaitWindow("#32770", "Confirm Save As", 1, 500).Exists)
myApp.dlgConfirmSaveAs.Confirm_Save_As.CtrlNotifySink.btnYes.ClickButton();
I don't really know where this "dlgConfirmSaveAs" came from or whether I can use that alias/namemapping (?) more directly than going via Sys.Process and using WaitWindow.
As mentioned I'm exploring options, learning as I go, and wondering about better techniques.