Every dog has a blog!
[ start | index | login or register ]
start > 2010-06-23 > 1

Extent Badboy to write a CSV-Logfile by using a JScript Tool Element

Created by derjohn. Last edited by derjohn, one year and 227 days ago. Viewed 547 times. #2
[diff] [history] [edit] [rdf]
labels
attachments
logentry.js (544)

Extent Badboy to write a CSV-Logfile by using a JScript Tool Element

From time to I use tool "Badboy" from Simon Sadedin to create functional tests for websites or web-based applications. Now I needed to extend the tests for logging the runtime of certain steps and the whole test, but the Badboy Tool doesn't offer such a counter out of the box. To I created some lines of JavaScript that can be used in Badboy via the the "JScript" tool element to log into a csv-file, which can be processed in Excel or Openoffice later on.

Instructions to setup

  1. Create a variable called "logfile" and set it's value to the name of the desired logfile, e.g. mylogfile.csv. (You can also define it with a path like "c:
    myfile.csv")
  2. Create a test file called "logentry.js" and place it in the same directory as your test. The content of the file is the script shown at the end of this blog entry.
  3. Add a "JScript Tool" to your testplan at the points where you want to write a timestamp into the logfile, select checkbox "Allow Access to Plugin Priviliges" and set the source to to the formerly created "logentry.js" file. (You can reference the script file with absolute or relative pathes. If you go for relative ones, the whole test can be simply transferred to other machines)
That's it! You can copy that element to all that points in your test, where you want to log a line. The logline will contain the host-Variable as well as the parent steps name and the name you gave to the JSctipt tool element.

The Code:

var datumzeit = new Date(); var stepname = badboy.script.find(badboy.current).parent.get('name'); var value = '"' + badboy.getVariable('host') + '","' + stepname + '","' + badboy.script.find(badboy.current).get('name') + '","' + datumzeit.toUTCString() + '","' + datumzeit.getTime() + '"' + " rn"; var fso = badboy.plugin.createObject("Scripting.FileSystemObject"); var textFile = fso.OpenTextFile( badboy.getVariable('logfile') + '-' + badboy.getVariable('host') + '.csv', 8, true); textFile.Write (value); textFile.Close();

Icon-Comment bryanfurry, one year and 86 days ago. Icon-Permalink

These kind of articles are always attractive and I am happy to find so many good point here in the post.

>>http://www.logo-genie.com

Please login to blog.derjohn.de.

< February 2012 >
SunMonTueWedThuFriSat
1234
567891011
12131415161718
19202122232425
26272829


Logged in Users: (0)
… and 2 Guests.

Blogrolling:
>>Blog des Wahnsinns
>>Daniel Holbach's Blog
>>Matt Cutt's blog
>>Randgruppentourismus

XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

Hinweise zur Formatierung
snipsnap-help.

Powered by
SnipSnap 1.0b1-snipit

Ads will be placed here!

dem john sein blog | Impressum: Andreas John, Frankfurter Str. 98a, 63067 Offenbach, E-Mail: himself@derjohn.de