Hi,
In our app we have an unexpected popup, which I can catch thanks to the codes examples in the doc.
When the popup appeared, I want to replay the test but I can't find anywhere how to do it.
If you need more details or you have any solutions, i'd be happy to discuss about it.
Thanks
Regards,
Jeff
__________________________
Setup:
Windows 7 Pro
Ranorex 6.1
Iphone 5 | IOS 10.0.2
Replay a test inside user code
Re: Replay a test inside user code
Hi,
I'm not sure how your test is structured, but if you want to start a module you can do so like below:
<Module Name>.Start();
Example: I have a recording module named "cheese" and I can start it via code like so:
cheese.Start();
I'm not sure about the structure of your test(s) but it may be possible for you to take advantage of error behavior settings or a teardown section.
Maybe a screenshot of how your test is structured and what exactly you wish to replay would be helpful.
I'm not sure how your test is structured, but if you want to start a module you can do so like below:
<Module Name>.Start();
Example: I have a recording module named "cheese" and I can start it via code like so:
cheese.Start();
I'm not sure about the structure of your test(s) but it may be possible for you to take advantage of error behavior settings or a teardown section.
Maybe a screenshot of how your test is structured and what exactly you wish to replay would be helpful.
Re: Replay a test inside user code
Hi Vega,
Thanks for your response, but it's not exactly what I want to do.
My post isn't clear, so here is exactly the behavior I expect:
I've a lot of recordings, inside different tests cases. In each tests a popup can appear, and I catch it thanks to the PopupWatcher.
This PopupWatcher launch a function, and in this function I want to replay the test where this popup appeared.
It's because this random popup make the test fails, so I want to restart the current recording where it happen. The problem is that it can be any test, not only one so I think I couldn't apply your response.
Here is a view of my code:
I hope it will help you.
Regards,
Jeff
Thanks for your response, but it's not exactly what I want to do.
My post isn't clear, so here is exactly the behavior I expect:
I've a lot of recordings, inside different tests cases. In each tests a popup can appear, and I catch it thanks to the PopupWatcher.
This PopupWatcher launch a function, and in this function I want to replay the test where this popup appeared.
It's because this random popup make the test fails, so I want to restart the current recording where it happen. The problem is that it can be any test, not only one so I think I couldn't apply your response.
Here is a view of my code:
void ITestModule.Run() { Mouse.DefaultMoveTime = 300; Keyboard.DefaultKeyPressTime = 100; Delay.SpeedFactor = 1.0; PopupWatcher myPopupWatcher = new PopupWatcher(); myPopupWatcher.Watch("what_I_want_to_catch", ReplayTest); myPopupWatcher.Start(); } public static void ReplayTest(Ranorex.Core.RxPath myPath, Ranorex.Core.Element myElement) { //Here I want to restart the current recording without breaking the test workflow. //The test where the popup appeared should be replace }Thanks again for your time,
I hope it will help you.
Regards,
Jeff
Re: Replay a test inside user code
Hi,
I'm afraid, there is no way to replay a specific TC from code. Also, the problem is that the popupwatcher runs from different thread and there is currently no way to pause/restart the main thread from popupwatcher/second thread (the only workaround seems to be something like >this<)
The only thing you can probably do is to save the failing TCs somewhere (text file or so) make the entire test to fail/wait for finish and then restart the test with only specific test cases specified in a command line?
I'm afraid, there is no way to replay a specific TC from code. Also, the problem is that the popupwatcher runs from different thread and there is currently no way to pause/restart the main thread from popupwatcher/second thread (the only workaround seems to be something like >this<)
The only thing you can probably do is to save the failing TCs somewhere (text file or so) make the entire test to fail/wait for finish and then restart the test with only specific test cases specified in a command line?
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Replay a test inside user code
Hi odklizec,
Thanks for your response, I will find a way like yours to replay the failed test cases after the run.
I will read carrefully your link,
Or maybe it will be very usefull to do like this for me:
-The popup appeared (OK)
-The popup watcher run my function (OK)
-My function break my recording (how?)
-My function close the popup (OK) and run the last action played (how?) in order to repair the recording (a touch for exemple)
-My function start the rest of my recording (how?)
So is there any possibilities to run the last action?
Unfortunately I think no, but why not...
Thanks for all
Regards,
Jeff
Thanks for your response, I will find a way like yours to replay the failed test cases after the run.
I will read carrefully your link,
Or maybe it will be very usefull to do like this for me:
-The popup appeared (OK)
-The popup watcher run my function (OK)
-My function break my recording (how?)
-My function close the popup (OK) and run the last action played (how?) in order to repair the recording (a touch for exemple)
-My function start the rest of my recording (how?)
So is there any possibilities to run the last action?
Unfortunately I think no, but why not...
Thanks for all
Regards,
Jeff
Re: Replay a test inside user code
Hi Jeff,
What could be done is to throw an exception in the popup watcher function. This doesn't fail your module/test case, but it would indicate an error in that test case.
I'm afraid there is no way to start the last played action and the rest of the recording after closing the popup.
What could be done is to throw an exception in the popup watcher function. This doesn't fail your module/test case, but it would indicate an error in that test case.
Code: Select all
public static void ReplayTest(Ranorex.Core.RxPath myPath, Ranorex.Core.Element myElement)
{
//Handle popup
Validate.Fail();
}
You do not have the required permissions to view the files attached to this post.
Re: Replay a test inside user code
Thanks jma,
I will use it in combination with odklizec answer, to force the test case to fail, warn the user and replay the test at the end.
I write the test cases in a temporary file, at the end I recover the test cases names as strings.
I want to launch this tests, but I'm not able to find how I can start a test case with only his name.
Somobody have any idea?
Thanks a lot,
Regards
jeff
I will use it in combination with odklizec answer, to force the test case to fail, warn the user and replay the test at the end.
I write the test cases in a temporary file, at the end I recover the test cases names as strings.
I want to launch this tests, but I'm not able to find how I can start a test case with only his name.
Somobody have any idea?
Thanks a lot,
Regards
jeff
Re: Replay a test inside user code
Hi,
You need to use /tc: command line parameter, as described here:
http://www.ranorex.com/support/user-gui ... html#c4827
Here is an example:
You need to use /tc: command line parameter, as described here:
http://www.ranorex.com/support/user-gui ... html#c4827
Here is an example:
Code: Select all
test.exe /tc:test_case_name_string
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Replay a test inside user code
Hi,
Thanks odklizec. In the popup handler, I'm only able to get the name of the current recording and not the test case.
So I can't replay the test case no?
Thanks,
Regards
Jeff
Thanks odklizec. In the popup handler, I'm only able to get the name of the current recording and not the test case.
So I can't replay the test case no?
Thanks,
Regards
Jeff
Re: Replay a test inside user code
Hi,
Luckily, there is a way to get the test case name from popup watcher thread.
Add this code to method called by popup watcher (the one which actually handles the unexpected dialog/element):
And this is the method, which returns actual test case name (at a time of processing popup watcher method):
Eventually, you can use this method to return the "root" TestCase name, instead of immediate TestCase name (in case of nested structure of test cases)...
Hope this help? I got the second method from Ranorex support and after a small modification (first posted method), it turned out to be useful also in your case
Luckily, there is a way to get the test case name from popup watcher thread.
Add this code to method called by popup watcher (the one which actually handles the unexpected dialog/element):
Code: Select all
TestModuleLeaf curModule = (TestModuleLeaf)TestModuleLeaf.Current;
string tcName = GetTestCaseName(curModule);
Code: Select all
public static string GetTestCaseName(TestSuiteEntry entry)
{
string tcName = string.Empty;
while (entry != null)
{
if (entry is TestCaseNode)
{
tcName = entry.Name;
break;
}
entry = entry.Parent;
}
return tcName;
}
Code: Select all
public static string GetTestCaseName(TestSuiteEntry entry)
{
string tcName = string.Empty;
while (entry != null)
{
if (entry is TestCaseNode && (!(entry as TestCaseNode).IsRootTestCase))
{
tcName = entry.Name;
break;
}
entry = entry.Parent;
}
return tcName;
}
Pavel Kudrys
Ranorex explorer at Descartes Systems
Please add these details to your questions:
Ranorex explorer at Descartes Systems
Please add these details to your questions:
- Ranorex Snapshot. Learn how to create one >here<
- Ranorex xPath of problematic element(s)
- Ranorex version
- OS version
- HW configuration
Re: Replay a test inside user code
Hi,
Thanks a lot it's exactly what I needed!
However I couldn't find anywhere how to launch several tests cases with code or command line, except by group this test cases inside a run config.
So how to create a run config and add tests inside with code? Or how to launch several tests with one command line?
Is it possible?
Regards,
Jeff
(Beginner)
Thanks a lot it's exactly what I needed!
However I couldn't find anywhere how to launch several tests cases with code or command line, except by group this test cases inside a run config.
So how to create a run config and add tests inside with code? Or how to launch several tests with one command line?
Is it possible?
Regards,
Jeff
(Beginner)
Re: Replay a test inside user code
Hi,
Solved, thanks for your response.
Regards,
jeff
Solved, thanks for your response.
Regards,
jeff