Screenshot is taken of incorrect object if test fails

Ask general questions here.
Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Screenshot is taken of incorrect object if test fails

Post by Martin » Thu Nov 05, 2015 12:03 pm

I've noticed for some time that quite often the screenshots taken for my report are from the incorrect monitor.
Until now I have been dealing with more urgent tasks but today I finally had the time to do some digging.

What I found out is that Ranorex actually takes the screenshot from the screen that the mouse cursor is on. The normal setup for me is having the testing tasks and automation be done in the main monitor and Ranorex Studio is open on the secondary monitor.

So I have a few questions related to this:
1) Why isn't the screenshot captured from lets say the Dom object of the test on hand but is related to where my mouse cursor is?

2) Is this a feature and does it have multiple options?

And about the context - haven't changed anything around capturing the screenshots so it's related to reports for Failed tests.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Screenshot is taken of incorrect object if test fails

Post by krstcs » Thu Nov 05, 2015 2:57 pm

First, it would help if you posted a screen shot of the test module where you are taking the screen shot, or a copy of the code that accomplishes it.

Second, did you specify an element in the screen shot action? If not, then Ranorex has no way to know what you want to take a screen shot of, so it takes one of the location where the mouse is, because most of the time, that is where the test is running. Add the DOM repo element of the AUT to the screen shot action and see if that helps.
Shortcuts usually aren't...

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: Screenshot is taken of incorrect object if test fails

Post by Martin » Thu Nov 05, 2015 3:12 pm

There probably is no need for me to take a screenshot of the object I want the screenshot taken of cause it's not an element specific issue. Neither is there a screenshot action specified by userCode or an action.

What I'm talking about is the default screenshots taken on fail. To add a screenshot action to every action Ranorex would otherwise take a screenshot of on fail (basically every action then) isn't a good idea either cause this just boosts the workload and the time to maintain the code.

My tests are also developed mostly wihtout cursor movement (only have 2 places where I HAVE to move it and make a click action). Meaning that my cursor will stay on monitor 2 after launching from the Studio.

But I can also see some logical issues when Ranorex would rely on the dom object for screenshots (as it might not exists in that specific fail scenario).

Let's be more specific then - Is it possible to change the functionality of taking the automatic screenshot on fail by where the cursor atm is to always taking it of Monitor 1? I wouldn't want to rely on remembering to move my cursor to the 1st monitor after running the tests or before going home from work for the nightly run.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

Re: Screenshot is taken of incorrect object if test fails

Post by krstcs » Thu Nov 05, 2015 4:46 pm

So, the easiest way to get around this is to add a single Mouse.Move at the very beginning of your test (right after the AUT is opened, for instance) that moves the mouse to the middle of the AUT.


If the AUT doesn't exist at the time of the screenshot (or the mouse move), it will fail, but if the AUT doesn't exist then there really isn't a point in taking a screenshot. The screenshot is there to help diagnose the failure, and if your AUT doesn't exist then your failure is probably at a point where Ranorex can't help anyway.
Shortcuts usually aren't...

Martin
Posts: 152
Joined: Fri Aug 15, 2014 12:24 pm

Re: Screenshot is taken of incorrect object if test fails

Post by Martin » Fri Nov 06, 2015 8:13 am

krstcs wrote:So, the easiest way to get around this is to add a single Mouse.Move at the very beginning of your test (right after the AUT is opened, for instance) that moves the mouse to the middle of the AUT.


If the AUT doesn't exist at the time of the screenshot (or the mouse move), it will fail, but if the AUT doesn't exist then there really isn't a point in taking a screenshot. The screenshot is there to help diagnose the failure, and if your AUT doesn't exist then your failure is probably at a point where Ranorex can't help anyway.
It has actually never been the issue of AUT not existing. It always does exist in these type of situations. And yeah I thought about this as a solution as well. It's more of a hack (and probably the easiest solution) but I'd rather get familiar with the screenshot taking logic.