When encountering an onbeforeunload alert dialog while automating tests with gauge the test freezes - getgauge

While automating a test using Gauge I have found that when I encounter an alert triggered by an window.onbeforeunload the test the execution of the test halts. The dialog text is:
Leave site? Changes you made may not be saved. "Leave" or "Cancel" buttons.
I have tried to solve this using the following:
1 - new Actions(DriverFactory.Driver).SendKeys(Keys.Return);
2 - DriverFactory.Driver.SwitchTo().Alert().Accept();
3 - sending keys to the body SendKeys(Keys.Return);
No matter what I try the following error comes up:
unexpected alert open
Even with a gauge message immediately after the backpage command it does not show on the report when gauge fails the test.
Gauge execution appears to completely stop when the dialog comes up.

I believe that you are correct. The driver was having issues executing the following code when the alert was open:
driver.Navigate().GoToUrl(url);
If I used buttons in the application, the driver did not hang and I was able to interact with the alert at that point. Thank You for the comment.

Related

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

VS2013 Coded UI test MouseClick on the close button of a dialogue form sometimes cannot close the form

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.

Providing delay between two codes in j2me

I am trying j2me code in which i am putting to thingd a alert message and setCurrentItem()
function..
display.setCurrent(alert);
display.setCurrentItem(textBox)
the problem is that before we can see the alert msg it disappear and because of display.setCurrent(textBox). what should i do to see the alert message correctly and than move to the item which is placed im display.setCurrentItem??
I don't really do any High Level GUI coding (meaning Form stuff), so I'm no expert.
But looking at the docs, I can see a setTimeout(int time) function on the Alert object.
So my guess is that you should display the TextBox first, and then display the Alert afterwards with a timeout.
alert.setTimeout(5000); // 5 seconds
display.setCurrent(textBox);
display.setCurrent(alert);
That should display the alert for 5 seconds, and then when dismissed, the textBox should appear.
Looking at the Display object, I also notice another function called setCurrent(Alert alert, Displayable nextDisplayable) though, which seems to be even better.
Using that method you should be able to just do
Display.setCurrent(alert, textBox);
The docs says the following about that method: "Requests that this Alert be made current, and that nextDisplayable be made current after the Alert is dismissed. This call returns immediately regardless of the Alert's timeout value or whether it is a modal alert. The nextDisplayable must not be an Alert, and it must not be null."
Bookmark and use this page a lot:
http://docs.oracle.com/javame/config/cldc/ref-impl/midp2.0/jsr118/

VS 12 shows new javascript runtime error in IE11P

I just upgraded to IE11P to test out the updated dev tools.
Now when I start to debug a project through VS12 a new 0x800a138f JavaScript runtime error: Unable to get property 'createRange' of undefined or null reference appears.
This happens when I type in my Ajax Combo Box that's bound to a data source with the text completion on.
This error has never popped up before the update to IE11, its never showed up in the browser consoles for IE10 and chrome.
when run without the debugger attached, it works like normal except it doesn't automatically all cap the text being entered under IE.
I am not really concerned over the error itself I would just like to suppress the annoying java runtime events.
See this post. It looks like this is an issue with IE 11, something waiting for a solution from Microsoft.

Capybara Cucumber test fail to find xpath when browser is minimized

I'm running a scenario where form fields are automatically filled in with invalid values which trigger some javascripts to show warnings under each incorrectly filled field when I blur.
The test passes when the browser is in focus. It finds the xpath with the "expected warning" that I pass. But if I minimize or just click on another application, it fails to find the xpath.
I'm running Firefox 3.6 (going to update it soon) and the way I'm doing to find the xpath is by using "page.should have_xpath(xpath)"
Does anyone have any idea how what might solve this? It's really important for me to run it with the browser minimized.
Edit and alternative solution:
I guess the timing issue that occurs in events such as blur followed by finding a certain xpath in a minimized browser inherent to the driver itself. Therefore, I decided to run the tests in a Virtual Frame Buffer using xvfb in Linux and it seems to be working really well. I'm planning on applying this to be triggered by Hudson/Jenkins whenever a change is committed.
Could it be a timing issue? Perhaps if the browser isn't frontmost and maximised, the rendering is not happening quickly enough for the content be present when Capybara checks for it.
Also: How are you triggering the blur event?

Resources