Hi,
we've got one MessageBox which appears some time after starting the application. It is not possible to say when this dialog appears. I was following your blog entry http://www.ranorex.com/blog/handling-di ... up-windows - but not successfully. At the moment my tests fail if this dialog pops up because the testexecution continues during the moment I'm dealing with the pop-up and the action of the test fails.
Here a short description what I've done:
- We are working with Testsuites
- Within the testsuite I call a module "StartApp"
- I created a new class with a method which creates a new thread checking if the dialog appears and handling it.
- This method is called during "StartApp"
My Problem is now, how to "pause" the main thread if the Dialog is found, so I can handle the dialog without interrupting the testexecution. I searched but did not find a solution how to access the main thread.
Has someone an idea how to do this?
Thank you in advance
Best regards
Anja
Handling unexpected Dialogs
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Handling unexpected Dialogs
Hello,
Unfortunately, it is not possible to handle with unexpected random dialogs.
Threads are a bit tricky to handle in applications. If you know when the dialog pops up you
could set the main thread in a waiting state e.g. Thread.Sleep(300). But the problem is that
you don't know when it happens.
The best solution would be to disable the dialog within your application if it is possible.
Regards,
Markus (T)
Unfortunately, it is not possible to handle with unexpected random dialogs.
Threads are a bit tricky to handle in applications. If you know when the dialog pops up you
could set the main thread in a waiting state e.g. Thread.Sleep(300). But the problem is that
you don't know when it happens.
The best solution would be to disable the dialog within your application if it is possible.
Regards,
Markus (T)
Re: Handling unexpected Dialogs
Hi,
if I understand your answer correctly, then it is possible to start a new thread from within the thread executing the tests but not possible to access the thread executing the tests from the new one....
Within the application it is not possible to turn off the appearance of this message dialog and it is even not possible to say when it appears because this depends on how many and which other components are installed on the PC running the application...
Maybe you can help me implementing this workaround.
So at the moment my tests are failing because one action was not successfully executed because of the handling of the unexpected dialog. In the report it is not clear why my tests are failing. I would like to have a report entry if the dialog has appeared.
I tried this like following:
In the method handling the dialog I put a Report.Warn() and write there my comment.
My problem is, that this message appears in the console output but not in the Report file. Is it possible to write this message in the same Report file as the other Test-outputs?
Thank you in advance
Best regards
Anja
if I understand your answer correctly, then it is possible to start a new thread from within the thread executing the tests but not possible to access the thread executing the tests from the new one....
Within the application it is not possible to turn off the appearance of this message dialog and it is even not possible to say when it appears because this depends on how many and which other components are installed on the PC running the application...
Maybe you can help me implementing this workaround.
So at the moment my tests are failing because one action was not successfully executed because of the handling of the unexpected dialog. In the report it is not clear why my tests are failing. I would like to have a report entry if the dialog has appeared.
I tried this like following:
In the method handling the dialog I put a Report.Warn() and write there my comment.
My problem is, that this message appears in the console output but not in the Report file. Is it possible to write this message in the same Report file as the other Test-outputs?
Thank you in advance
Best regards
Anja
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: Handling unexpected Dialogs
Hello,
It is possible to suspend and resume the Main thread from another thread. But this could lead to a deadlock. You would need to prioritize your 'CheckPopUps' thread higher than the Main thread.
Additionally, you would need to stretch the execution time for each action.
Please consider that there is no guarantee that is will work.
Please take a look at 'Using Threading' from MSDN to get more info on handling threads.
http://msdn.microsoft.com/en-US/library ... 80%29.aspx
The test execution thread could only log a report entry if it checks all the time when a dialog pops up.
Reporting is only supported in Main thread (executing tests).
Unfortunately, it is not possible to do that in a second thread that checks pop-ups.
Regards,
Markus (T)
It is possible to suspend and resume the Main thread from another thread. But this could lead to a deadlock. You would need to prioritize your 'CheckPopUps' thread higher than the Main thread.
Additionally, you would need to stretch the execution time for each action.
Please consider that there is no guarantee that is will work.
Please take a look at 'Using Threading' from MSDN to get more info on handling threads.
http://msdn.microsoft.com/en-US/library ... 80%29.aspx
The test execution thread could only log a report entry if it checks all the time when a dialog pops up.
Reporting is only supported in Main thread (executing tests).
Unfortunately, it is not possible to do that in a second thread that checks pop-ups.
Regards,
Markus (T)