cancel
Showing results for 
Search instead for 
Did you mean: 

read number of recent logs keep from script

SOLVED
Regular Contributor

read number of recent logs keep from script

hi,

can I read options.engines.log.number of recent logs keep from a script?

i'd like to additionally export .mht log file copies and limit their number..

 

Regards,

Manfred

1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: read number of recent logs to keep from script

Hi @Manfred_F 


@Manfred_F wrote:

thanks,

the option seems not to be accessible via script.

What I tried to is:

- copy the current log file to .mht, if test is run via TestExecute, and

- limit the number of .mht log files automatically, as TC limits the number of original logs.

 

Regards,

Manfred


 

If you want to limit the number of MHT files, you can create a script that will do the following:

 

1) check the number of MHT files in a folder where you store test logs. You can do this via 

aqFileSystem.GetFolderInfo(<Path>)Files.Count

 

2) if the number of files is good for you (for example, less than 10), export the test log via

Log.SaveResultsAs

 

3) if the number of files isn't good, do some actions with the old MHT files (delete them or move to another folder)

 

Does this approach work for you?

---------
Tanya Gorbunova
SmartBear Community Manager

Join the annual community event and share your stories to win gifts
Wintertainment2019

View solution in original post

8 REPLIES 8
Community Hero

Re: read number of recent logs keep from script

I'm not sure I understand the question.  What are you trying to do?

As far as I can tell, that particular option is not accessible via code.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Manager

Re: read number of recent logs keep from script

Hi @Manfred_F,

 

The the Scripting Access to the Test Log Contents article contains a detailed description of how you can work with the log items. Does it help?

---------
Tanya Gorbunova
SmartBear Community Manager

Join the annual community event and share your stories to win gifts
Wintertainment2019
Regular Contributor

Re: read number of recent logs to keep from script

thanks,

the option seems not to be accessible via script.

What I tried to is:

- copy the current log file to .mht, if test is run via TestExecute, and

- limit the number of .mht log files automatically, as TC limits the number of original logs.

 

Regards,

Manfred

Super Contributor

Re: read number of recent logs to keep from script

Hi Manfred,

 

What I do is a "mobile supress" of some of my files in some folders.

I built a generic method that takes in input :

- a path

- a file extension

- a duration (in days)

 

I call this method every day in several places

It loops in the folder, and delete every file that matches the extension and that have its last file modification that exceeds the duration that is precised.

 

you just have to call such function at every time you run your script.

Contributor

Re: read number of recent logs keep from script

You can get access to the Logs using. Project.Logs.Count with top 1st result will start with 0 & there respective child status Pass and Fail by log.ErrCount for each of them.

Community Hero

Re: read number of recent logs keep from script

Not quite what was being asked...  they are looking for the ability to limit the number of exported logs on drive based upon the option being stored for max number of logs?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Manager

Re: read number of recent logs to keep from script

Hi @Manfred_F 


@Manfred_F wrote:

thanks,

the option seems not to be accessible via script.

What I tried to is:

- copy the current log file to .mht, if test is run via TestExecute, and

- limit the number of .mht log files automatically, as TC limits the number of original logs.

 

Regards,

Manfred


 

If you want to limit the number of MHT files, you can create a script that will do the following:

 

1) check the number of MHT files in a folder where you store test logs. You can do this via 

aqFileSystem.GetFolderInfo(<Path>)Files.Count

 

2) if the number of files is good for you (for example, less than 10), export the test log via

Log.SaveResultsAs

 

3) if the number of files isn't good, do some actions with the old MHT files (delete them or move to another folder)

 

Does this approach work for you?

---------
Tanya Gorbunova
SmartBear Community Manager

Join the annual community event and share your stories to win gifts
Wintertainment2019

View solution in original post

Highlighted
Regular Contributor

Re: read number of recent logs to keep from script

Thank You all for the info