Reputation: 171
We have a Form that is shown as a Dialogue above the main Form. DialogResult rslt = cvForm.ShowDialog();
In Coded UI test, immediately when the Dialogue is lunched, the Mouse.Click tries to close it by clicking the "x" button of the Form. However, seems the x button cannot respond the click event sometimes, on a certain machine it always fails to close the Form unless we put a wait before the click. All WaitForControlxxx() does not serve as wait because they immediately returns. Only putting PlayWait(1000) before the click works and can close the Form. And the failure only happens on our lab machine. On my laptop, even without PlayWait(1000), it works fine. Seems it's only a timing issue. Is there anything I can wait for instead of blindly wait for 1 second in order for it to work on the lab machine?
//this.UIAUDIO_TX_HPF_IIRWindow refers to the Form shown as a Dialogue:
// this.UIAUDIO_TX_HPF_IIRWindow
//ulCloseButton refers to the "x" button on the Form:
WinButton uICloseButton = this.UIAUDIO_TX_HPF_IIRWindow.UIAUDIO_TX_HPF_IIRTitleBar.UICloseButton;
The following code cannot close the WinForm window on our lab machine, but CAN close it on my laptop machine:
uICloseButton.WaitForControlExist();
uICloseButton.WaitForControlReady();
uICloseButton.WaitForControlEnabled();
this.UIAUDIO_TX_HPF_IIRWindow.WaitForControlReady();
//Mouse.Click(uICloseButton, new Point(15, 9));
Mouse.Click(uICloseButton);
The following code CAN close the WinForm window on our lab machine:
Playback.Wait(1000);
Mouse.Click(uICloseButton);
Any comments?
Upvotes: 1
Views: 477
Reputation: 77
It seems dialog is not completely ready to change focus on dialog. Before focus gets ready, test is trying to close it. Try with following code.
Playback.PlaybackSettings.WaitForReadyLevel = WaitForReadyLevel.AllThreads;
Here WaitForReadyLevel.UIThreads
option also present.
This will increase test execution time.
Upvotes: 2