Monitor Ranorex log file while running tests

Ask general questions here.
keith
Posts: 14
Joined: Thu Nov 27, 2014 2:07 pm

Monitor Ranorex log file while running tests

Post by keith » Fri Nov 28, 2014 9:43 am

I would like to do the following.
Trigger a test suite manually on my machine from the Ranorex Studio application and monitor the running log of the test suite. Basically, I want to monitor using an external tool what is currently being output to the cmd window. I assume this is being output to a log file or could be forced do to so. This is what I mean by "log file". I guess this might be possible by additionally directing the console output to a file (if this is not already being done). I just wouldn't know where to begin to do tell Ranorex how to do that.

Why do I want to do this?
I sometimes work on more than one thing at a time and don't want to watch my automation running to see if everything is going okay. (This is usually during the refactoring and cleanup phase of test creation.) I use a simple little tool when testing that monitors a log file for a regex and then plays a .avi sound when the regex is found. For example, I have a regex for "error" and then a particular sound is played. This then gets my attention and I can decide whether to break the test suite and fix the problem or let it continue.

I hope someone can give me some hints on how I could achieve this using either the way I think it can be done above or some other way.
Cheers,
keith

swmatisa
Posts: 122
Joined: Fri Aug 05, 2011 7:52 am

Re: Monitor Ranorex log file while running tests

Post by swmatisa » Fri Nov 28, 2014 4:48 pm

Hello,

I do something similar. See http://www.ranorex.com/forum/ranorex-re ... tml#p11489

Regards
Hope this helps
SW

keith
Posts: 14
Joined: Thu Nov 27, 2014 2:07 pm

Re: Monitor Ranorex log file while running tests

Post by keith » Mon Dec 01, 2014 1:51 pm

Hi swmatista,
Thanks for your response.

I don't understand what you were trying to do there, exactly. My best guess would be that you are creating your own log file somehow with some code. Why can't we just access in real time the Ranorex console output that I can see posting to my screen while the test is running or redirect it to a log file? Is this not possible?

(Sorry. I am no programmer. I have no idea where those code snippets would need to go.I am not really making the connection between what you did/propose and what I want to have.)

Cheers,
Keith
Cheers,
keith

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

Re: Monitor Ranorex log file while running tests

Post by krstcs » Mon Dec 01, 2014 3:20 pm

Keith,

What you are attempting to do would require coding skills and cannot be done through Ranorex specifically, but might be possible through .NET.


I would suggest that if you are using Ranorex you need to learn to code. You don't "need" it to create simple tests, but it will help tremendously in understanding what Ranorex does and in the future will probably be very useful when you need to test more complex structures. Get a .NET for Dummies book and read it, preferably C# as it is a more common language and mirrors other languages' syntax (such as Java and C/C++). (Note: Not saying you are a dummy, but the "for Dummies" books are generally very well done and easy for beginners to understand. :D )

If you are using Ranorex, you are developing software, they just put a lot of the framework together for you already...
Shortcuts usually aren't...

keith
Posts: 14
Joined: Thu Nov 27, 2014 2:07 pm

Re: Monitor Ranorex log file while running tests

Post by keith » Tue Dec 02, 2014 3:18 pm

Hi krstcs,

I am quite comfortable with basic coding and am learning c# at the moment. Even though I know more than nothing, I am no programmer but that isn't really related to my question as far as I can tell. I was not making the connection to writing code in order to solve my problem.

I asked a very (what seemed to me) straightforward question. When I use the application Ranorex Studio to execute a test suite, there is a console output. I want to use this output in a specific way. The output (as far as I can tell) is already being created for me since I can see it on my screen. Now either Ranorex has or has not provided the ability to access this data at run time. I didn't not know.

I have put on my investigative tester hat for a few minutes today and spent some time wandering around in the Ranorex install and project directories and was able to determine that Ranorex is using the NLog utility for logging and for the console output.

http://nlog-project.org/

I guess I just need to familiarize myself with the appropriate settings for NLog to see if it can meet my needs. Perhaps I just need to find an appropriate wrapper type and target and that will be sufficient.

Here is the (I assume) default NLog.config.
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.netfx20.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true">
  <targets>
    <target name="console" xsi:type="ColoredConsole"/>
  </targets>
 <targets>
    <default-wrapper xsi:type="AsyncWrapper" />
    <target name="logfile" xsi:type="File" fileName="${processname}.log" />
    <target name="sentinel" xsi:type="NLogViewer" newLine="true" address="udp://127.0.0.1:36814" keepConnection="true"/>
  </targets>
  <rules>
    <!-- Valid log levels are: Trace, Debug, Info, Warn, Error, Fatal -->

    <!-- Set the minlevel attribute to enable logging to the console -->
    <logger name="*" minlevel="Off" writeTo="console" />

    <!-- Set the minlevel attribute to enable logging to a local file -->
    <logger name="*" minlevel="Off" writeTo="logfile" />

    <!-- Set the minlevel attribute to enable logging to a local UDP listener (e.g. Sentinel) -->
    <logger name="*" minlevel="Off" writeTo="sentinel" />
  </rules>
</nlog>
If anyone has any further suggestions the please let me know.

Cheers,
Keith
Cheers,
keith

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Monitor Ranorex log file while running tests

Post by Support Team » Thu Dec 04, 2014 1:09 pm

Hello Keith,

I’m not sure which tool you are using for acoustically signaling that something happened. The tool needs either the capability to retrieve information from the consoles or from an UDP port. If that is possible, you could use the logging information which is generated from Ranorex.

Please note that our logging provides much more information than just the Ranorex messages which are logged to the Report file. This internal information will generate a huge overhead. Therefore, I don’t think this mechanism is the best choice for your needs.

It would be easier to use the already mentioned IReportLogger in order to create a custom behavior for specific events.

Regards,
Robert
.
Image

keith
Posts: 14
Joined: Thu Nov 27, 2014 2:07 pm

Re: Monitor Ranorex log file while running tests

Post by keith » Fri Dec 05, 2014 9:51 am

Okay thank you Robert and for all others that answered. When I get the time I will try this out. It isn't a high priority for me, I just wanted to see if it could be easily done without such a big deal before I pursued it. I will post here if I get around to doing it to share my results.
Cheers,
keith