The following code seems to work roughly 50% of the time. If I run this code 10 times it stops after the file upload dialog opens, it just hangs and doesn't do anything else.
I run this on an open screen
I don't touch the mouse or anything else that could interfere.
Any ideas??
//Saves tmp image
Bitmap image = currentTest.ActiveBrowser.Window.GetBitmap();
image.Save(imagePath);
currentTest.ActiveBrowser.Manager.DialogMonitor.Start();
for (int i = 0; i < count; i++)
{
FileUploadDialog fileUp = new FileUploadDialog(currentTest.ActiveBrowser, imagePath, DialogButton.OPEN);
currentTest.ActiveBrowser.Manager.DialogMonitor.AddDialog(fileUp);
currentTest.ActiveBrowser.Find.ByExpression<HtmlInputFile>(attachFileInput).Click();
fileUp.WaitUntilHandled(SharedValues.DefaultTimeout);
currentTest.ActiveBrowser.Manager.DialogMonitor.RemoveDialog(fileUp);
}
currentTest.ActiveBrowser.Manager.DialogMonitor.Stop();
12 Answers, 1 is accepted
I'm running MSTEST and i just did an experiment.
Running this test alone or running it as the first test it fails about 50% of the time
Running it as the second test or just not the first one it seems to work every time.
Ideas?
Instead of creating and destroying a new FileUploadDialog, try creating and resetting just one FileUploadDialog object like this:
//Saves tmp image
Bitmap image = currentTest.ActiveBrowser.Window.GetBitmap();
image.Save(imagePath);
currentTest.ActiveBrowser.Manager.DialogMonitor.Start();
FileUploadDialog fileUp =
new
FileUploadDialog(currentTest.ActiveBrowser, imagePath, DialogButton.OPEN);
currentTest.ActiveBrowser.Manager.DialogMonitor.AddDialog(fileUp);
for
(
int
i = 0; i < count; i++)
{
currentTest.ActiveBrowser.Find.ByExpression<HtmlInputFile>(attachFileInput).Click();
fileUp.WaitUntilHandled(SharedValues.DefaultTimeout);
fileUp.CurrentState = DialogCurrentState.NotActive;
//currentTest.ActiveBrowser.Manager.DialogMonitor.RemoveDialog(fileUp);
}
currentTest.ActiveBrowser.Manager.DialogMonitor.Stop();
Cody
the Telerik team
Test Studio Trainings
I tried what you suggested and it doesn't make a difference, here is some more info:
- Running the test as part of other tests where it's not the first seems to work
- Running in debug mode works every time
- When it fails it never throws an exception it just hangs and stops all other tests
So I'm still having exactly the same problem.
Sorry for the delay getting back to you. I admit this should be easier, and I've filed a bug on this here, I did get this code working for me very reliably using IE9:
FileUploadDialog upDlg =
new
FileUploadDialog(ActiveBrowser, @
"E:\Temp\configuration.php"
, DialogButton.OPEN);
Manager.DialogMonitor.AddDialog(upDlg);
HtmlInputFile fileUpload = ActiveBrowser.Find.ByName(
"upfile"
).As<HtmlInputFile>();
for
(
int
i = 0; i < 10; i++)
{
fileUpload.Click();
upDlg.WaitUntilHandled(10000);
Manager.DialogMonitor.RemoveDialog(upDlg);
upDlg =
new
FileUploadDialog(ActiveBrowser, @
"E:\Temp\configuration.php"
, DialogButton.OPEN);
Manager.DialogMonitor.AddDialog(upDlg);
System.Threading.Thread.Sleep(100);
}
Cody
the Telerik team
Test Studio Trainings
It doesn't make a difference, it's still very unstable. Also we're seeing the same behavior on the other dialog handlers as well.
Our workaround right now is, don't run a test that uses a dialog as the first test then it seems to work.
Below is another code snippet that shows the same behavior:
_manager.DialogMonitor.AddDialog(ConfirmDialog.CreateConfirmDialog(currentTest.ActiveBrowser, confirm ? DialogButton.OK : DialogButton.CANCEL));
_manager.DialogMonitor.Start();
HtmlInputSubmit btnSendToApprove = currentTest.Find.ByExpression<HtmlInputSubmit>(
"tagname=input"
,
"id=~btnSendtoApproval"
);
btnSendToApprove.Click();
Exactly the same happens:
Running first - Fails
Running alone - Fails
Running in Debug - Works
Running as second test - Works
NOTE:
We are running IE8 currently.
I have tried to reproduce your exact symptom with no success so far. Can you send me a complete test project I can run on my machine to reproduce these symptoms you describe:
Running first - Fails
Running alone - Fails
Running in Debug - Works
Running as second test - Works
Cody
the Telerik team
Test Studio Trainings
I can't send you the full project but I have created a new project and managed to reproduce the same behavior.
And I have narrowed it down a bit, it seems to be related to code coverage. Our test project is in the same solution as a unit test project which uses code coverage and it seems when I turn off code coverage Teleriks works fine but when it's on, dialog issues appear.
But how do i send you a private message?
Is the file under 10MB? You can send it as an email attachment to support@telerik.com. Please reference ticket 514290 in the email so that it will be correctly directed to me.
Greetings,Cody
the Telerik team
Test Studio Trainings
Did you get the project? I sent it but wasn't sure if it got through the company firewall.
Yes I just received it. Thank you! I haven't had any time yet to try it (since I just got into the office). I'll be working on it soon today.
Greetings,Cody
the Telerik team
Test Studio Trainings
Thanks for the project. I was able to reproduce the problem. I tried to figure out what is causing it with no success. I filed a bug on this here. Hopefully our developers can figure something out about this.
Regards,Cody
the Telerik team
Test Studio Trainings
Ill monitor the bug process