Read values from Notepad

Ask general questions here.
Sai
Posts: 22
Joined: Tue Jul 18, 2017 10:59 am

Read values from Notepad

Post by Sai » Thu Aug 24, 2017 1:10 pm

Hello Users,

I have attached 1 log files in which a line needs to be validated. Position of this validation point may differ and please find the below validation strings

Need to get values before and after ' RunPackage.exe Version: '
Need to get values after Host Name: or OS Version
08/10/2017 21:24:06 :: Exiting with Error Code: 0
Product Name: Adobe Acrobat Reader DC MUI. Product Version: 17.009.20044. Product Language: 1033. Manufacturer: Adobe Systems Incorporated. Reconfiguration success or error status: 0.

I have worked already with some regular expression get values but not succeed.

Please help me out from this.

Thanks,
Sai
Attachments
InstallLog.log
(23.85 KiB) Downloaded 26 times

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

Re: Read values from Notepad

Post by odklizec » Thu Aug 24, 2017 1:31 pm

Hi,

In my opinion, it's pointless to read the lines from notepad. I would suggest to load entire file into memory (using I/O methods) and process the file using a combination of string manipulation methods and regexes. I'm currently out of computer, but I'm sure you can find many relevant code samples via google.
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

Sai
Posts: 22
Joined: Tue Jul 18, 2017 10:59 am

Re: Read values from Notepad

Post by Sai » Mon Aug 28, 2017 5:48 am

Thank you for your reply.

I have scenario that need to read some values from log files (Notepad) after installation of some files.

The above log file contains large data so Ranorex is reading some data from log file, not all data.

Is there any configurations/settings to read all the data in log files?

And plaese share us some related RE for above scenarios?

Thanks,
Sai

Sai
Posts: 22
Joined: Tue Jul 18, 2017 10:59 am

Re: Read values from Notepad

Post by Sai » Tue Aug 29, 2017 10:47 am

Hello Users/Ranorex Team,

Please support for above.

Thanks in Advance
Sai

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

Re: Read values from Notepad

Post by krstcs » Tue Aug 29, 2017 2:41 pm

This is not really a Ranorex issue, but more of a standard .NET issue. You will need to use the .NET IO library and read from the file directly.

Your best bet would be to google ".NET read file".

From that point you need to compare what you read to what you expect.
Shortcuts usually aren't...

Sai
Posts: 22
Joined: Tue Jul 18, 2017 10:59 am

Re: Read values from Notepad

Post by Sai » Thu Aug 31, 2017 8:17 am

Thank you for support.

yes, this is not really a Ranorex issue, i have followed documentaion at https://www.ranorex.com/help/latest/code-examples and i am able search for particular text without using RE like below

string file_installLog = @"../../Notepad/installLog.log";

// Read text line by line from file
string[] installLog = System.IO.File.ReadAllLines(file_installLog);

foreach (string line in installLog)
{
// Report.Info("",line); // print all line

if(line.Contains("Exiting with Error Code"))
{
Report.Info("",line);
Report.Success("Text is found");
}

}


Sai