Dynamic Error Behavior in Code Module

Ask general questions here.
bchesley
Posts: 2
Joined: Tue Aug 14, 2018 1:01 am

Dynamic Error Behavior in Code Module

Post by bchesley » Tue Aug 14, 2018 8:18 pm

Hello,

I'm wondering what the correct way is to change/alter the Error Behavior inside of a Code Module.

I have 10 Test Cases inside of a Smart Folder and if a certain situation arises, I want to fail out of the Smart Folder, but if it fails a different way, I want to only fail out of the current Test Case.

Basically I want to know the correct way to change the current behavior to either continue with sibling or continue with parent or whatnot, inside a Code Module.

Any help is appreciated.
Thanks!

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: Dynamic Error Behavior in Code Module

Post by qwertzu » Thu Aug 16, 2018 3:06 pm

Hey,

The following code snippet should help you:

Code: Select all

TestCaseNode currentNode=(TestCaseNode)TestSuite.Current.CurrentTestContainer;
			currentNode.ErrorBehavior= ErrorBehavior.ContinueParent;

regards, qwertzu

bchesley
Posts: 2
Joined: Tue Aug 14, 2018 1:01 am

Re: Dynamic Error Behavior in Code Module

Post by bchesley » Sat Sep 01, 2018 2:55 am

qwertzu wrote:
Thu Aug 16, 2018 3:06 pm
Hey,

The following code snippet should help you:

Code: Select all

TestCaseNode currentNode=(TestCaseNode)TestSuite.Current.CurrentTestContainer;
 currentNode.ErrorBehavior= ErrorBehavior.ContinueParent;

regards, qwertzu
To get back to you on this, I have tried the above and it was error free on compile, but while running, the code never gets past the first of the two lines above and I'm getting a, "Error in popup dialog handler.", message in the logs where it stops.

I have no idea why it would get stuck there.

User avatar
qwertzu
Posts: 284
Joined: Wed Jan 25, 2017 11:08 am

Re: Dynamic Error Behavior in Code Module

Post by qwertzu » Mon Sep 03, 2018 12:36 pm

Hi,

The code works perfectly fine on my side.
It seems like you somewhere implemented a popup watcher that runs in a second thread which causes the error.
The message does not seem to be related to the code for changing the error behavior.
So, could it be that you have implemented a popup watcher or something similar?
Also, please always post the whole error message, so the community can better help you with your issue.


regards, qwertzu

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Dynamic Error Behavior in Code Module

Post by odklizec » Mon Sep 03, 2018 1:11 pm

Hi

Agree with qwertzu. It seems you are implemented the 'decision' code directly in the popupwatcher method? But I don't think it can be done this way. As qwertzu mentioned, popupwatcher runs in a separate thread and it cannot interact with the main thread. What you might need to do is to add a decision code module to each test case/smart folder and eventually change the error behavior from the code module, instead of doing it in popup watcher.
Pavel Kudrys
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