Hi Everybody,
I'd like to know if there is a chance to overwrite (override?) Ranorex's ObjectNotFoundException to always be a general RanorexException.
Background: We are using Ranorex together with Aqua (Testmanagement Tool) and Aqua only reacts to a "RanorexException"; it keeps on processing the testcase when Ranorex, for example, creates an ObjectNotFoundException. That's not sensible and certainly needs to be addressed on Aqua's side but for the time being I simply need some workaround.
Overwrite ObjectNotFoundException
Overwrite ObjectNotFoundException
Vorsprung durch Wahnsinn
www.Doktor-Andy.de
www.Doktor-Andy.de
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: Overwrite ObjectNotFoundException
Hi,
The best way I found to throw a custom exception in case of an element not found, is to use the ActivityStack (internal API - so no docu available and can change in any Ranorex update). The code snippet is intended to be used within a global teardown section of your test:
Robin
The best way I found to throw a custom exception in case of an element not found, is to use the ActivityStack (internal API - so no docu available and can change in any Ranorex update). The code snippet is intended to be used within a global teardown section of your test:
Ranorex.Core.Reporting.ActivityStack.Instance.VisitAll(a => { var act = a as TestContainerActivity; if (act != null) { if (act.ResultSummary.Contains("Failed to find item")) { throw new RanorexException("MyCustomRxException"); } } return true; });Cheers,
Robin

Re: Overwrite ObjectNotFoundException
Hi Robin,
thanks a lot for the quick response.
Can you give me aother quick hint where I can find 'TestContainerActivity' (using directive)?
[Update]got it: Ranorex.Core.Reporting.TestContainerActivity [/Update]
And: how on earth does someone know about those deeply burried internals?
thanks a lot for the quick response.
Can you give me aother quick hint where I can find 'TestContainerActivity' (using directive)?
[Update]got it: Ranorex.Core.Reporting.TestContainerActivity [/Update]
And: how on earth does someone know about those deeply burried internals?
Vorsprung durch Wahnsinn
www.Doktor-Andy.de
www.Doktor-Andy.de
- RobinHood42
- Posts: 324
- Joined: Fri Jan 09, 2015 3:24 pm
Re: Overwrite ObjectNotFoundException
Hi,
Great !
Cheers,
Robin
Great !
Years of usage of Ranorex and some trial and errorhow on earth does someone know about those deeply burried internals?

Cheers,
Robin
Re: Overwrite ObjectNotFoundException
Plus thorough and frequent search of this forum, which is full of similarly handy code snippets 

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