VS2013 Coded UI test MouseClick on the close button of a dialogue form sometimes cannot close the form - coded-ui-tests

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?

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.

Related

FlxButtonPlus not responding to anything inside of game's pause menu

I am using the haxeflixel game framework to create a game and I was making a pause menu. I tried using the default FlxButton but the collision with the mouse never lined up properly. So I tried using FlxButtonPlus because it had some cool hooks but the button will not respond to any inputs. here is my code declaring the button in the pause menu
final unpausebut = new FlxButtonPlus((FlxG.width / 2) - 80,(FlxG.height / 2) - 10,unpause,"unpause",48,16); unpausebut.loadButtonGraphic(buttonNormal,buttonHovered); add(unpausebut);
Here is a picture of the pause menu itself so far.
but the button doesn't seem to respond to anything. I am also getting no errors inside of the terminal. unpause is a function inside of the code that also closes the substate. Can anybody help?

Show a form as dialog but keep going in the main form

I have a tool that starts and stops services. When a service is being started, I want to show a form that simply shows "Please wait while the service starts". I created a form that has a label and a progress bar in marquee-mode. When that form is shown, I want the main form to be blocked. So I called the please wait form with .ShowDialog. But of course, that stops the main form until the please wait dialog is closed. So I simply used .Show for the please-wait-dialog. So I call this:
PleaseWaitDialog.Show()
service.Start()
service.WaitForStatus(ServiceControllerStatus.Running)
PleaseWaitDialog.Dispose()
However, the PleaseWait dialog is shown but the waiting for the service to start stops the whole GUI so that the progress bar won't show the marquee.
How can I show the PleaseWait-dialog and make the progress bar do the marquee but also keep the program running and waiting for the service to start? I guess it has something to do with multi threading but I am not very familiar with that.
I tried using .ShowDialog which let's the GUI on the please wait form do its thing but that of course stops all other things that should be done while that dialog is shown

How to cancel all downloads in Chrome extensions and avoid displaying Save As dialog?

I'm trying to cancel every download just as they are started.
Here's my code so far:
var downloadCreated = function (a) {
// cancel the download
chrome.downloads.cancel(a.id);
chrome.downloads.erase({id: a.id}, function (d) {
});
};
chrome.downloads.onCreated.addListener(downloadCreated);
I've set Chrome to display Save As dialog when downloads are about to start.
I run my extension and click on a link several times. Sometimes the download is simply cancelled (which is the exact behavior that I want), and sometimes the Save As dialog is displayed. Clicking on Save button in the dialog has no effect and nothing will be downloaded. Whether the dialog is shown or not is random.
I'm just trying to avoid displaying the Save As dialog by any means.
Do you guys know a solution for this?
I found the solution some time ago but forgot to provide the answer. Here it is:
To stop a Chrome download attempt, chrome.downloads.cancel should be called in the proper event, that is chrome.downloads.onDeterminingFilename. That's it! No useless save dialogs will appear.

Automated Clicking Problem

I am coding up a program for automated testing which randomly clicks an open application window using various User32.dll library calls. My current problem is this, if a click would open a dialog, using Process.WaitForInputIdle() does not wait long enough for that dialog to be detected the next trip around the loop, which means several clicks get cued and if those clicks happen to be on something in the dialog I want to avoid (say an exit button) there is no way of telling that in advance. My question is this. Is there a way of waiting for the process or thread to finish all processing and only be waiting in the message loop again?
I hope that made sense.
Cheers
Ross
EDIT
Failing this, would it be somehow possible to set the process / threads of the target program and my program to both use the same processor and adjust the prioritorys of each so that the target program gets preference?
WaitForInputIdle will unfortunately return as soon as the app is in a message loop with no input messages waiting.
If you own the code to the dialog, you could have the dialog call SetEvent in its WM_INITDIALOG to signal your automation that it is ready for testing. Alternatively, you could look at using SetWinEventHook on the process and wait for the dialog to actually be created before sending input events to it.
The way around this it seems is to use the SendMessage API instead of the mouse_event or SendInput API. The reason for this is that SendMessage blocks until it has been processed. Just make sure you always get the handle of the window immediatly under where you want to click (using WindowFromPoint) and convert the mouse coordinates from screen to client coords using ScreenToClient. Pack the coordinates into the lParam parameter by using ((pt.Y << 16) + pt.X). This will block until processed and so any modal dialogs shown will block this call.

How to change the function called when I click in the close button on php-gtk?

I load a single instance of a window on php-gtk, I have a button named "Cancel" that hide(); the window, so when the window is needed again I just show();.
But when I click on the close button instead of the cancel button the window is destroyed. Even when I redirect the event (I'm not sure if i'm doing it right) it calls the first(just hide() function) and then the destroy method.
Any idea?
PD: I wouldn't want to destroy and recreate the windows because of php's crappy garbage collector and to be able to maintain previous data without having to refill the whole window(after all is supposed to be a desktop app).
Following the advice here: delete-event.
I changed my code to return TRUE:
function on_multipleCancelButton_activate()
{
global $GladeMultiple;
$MultipleWindow = $GladeMultiple->get_widget('multipleWindow');
$MultipleWindow->hide();
return TRUE;
}
On the GTK designer I linked the delete-event to this function.

Resources