Wednesday, February 17, 2010

Recursive search on the filesystem for the content of a log-file

I had the following problem lately:

On a test server I was looking for a log-file on the installation path and/or one of its sub-folders with some information about a "session timeout".

I didn't know the the log-files name, but new, that it had the extension ".log". I also didn't know which exception was was creating the entry. All I had, was the string "session timeout".

With the following Groovy script I could find all the log-files containing the string "session timeout" and from there it was easy to identify the log-file.


def dir = 'C:/some_installation_folder'
def fileExtension = '.log'
def searchString = 'session timeout'

new File(dir).eachFileRecurse() { f ->
if (f.directory) {
def p = ~/.*\${fileExtension}/
f.eachFileMatch(p) { log ->
def exceptions = []

log.eachLine { ln ->
if (ln =~ '.*' + searchString + '.*') {
exceptions << "${ln}"
}
}

if (!exceptions.empty) {
println log
exceptions.each{println " $it"}
}
}
}
}


Enjoy! :)

Tuesday, January 19, 2010

Date Format Fix in Excel 2003

Due to an issue in Excel 2003, sometime the date formats are not updated in the cells, which leads to the problem, that a cell shows a date but is not read as a date by macros and formulas.

You could go through each cell, press 'F2' and 'Enter' and Excel would finally identify the content of the cell as a date. But this you would do manually and not by script.

With the following VBA script for Excel, the format can be updated:


Sub UpdateColumnFormat()

Dim usedRangeOfRows As Integer
usedRangeOfRows = ActiveSheet.UsedRange.Rows.Count

'Date
Columns("A:A").Select
Dim e As Range
Dim currentValueE As Date
For Each e In Range("A2:A" & usedRangeOfRows).Cells
e.Select
currentValueE = ActiveCell.Value
ActiveCell.FormulaR1C1 = currentValueE
Next

End Sub


This problem occurs regularly, when I copy data from one sheet to another by VBA scripts.

With the above script, I could fix (at least work around it) this issue.

Enjoy :)

Monday, January 18, 2010

"Create List..." in Excel 2003 with VBA

While working on data within Excel with VBA, I like to use dynamic lists to address the data and eventually to give it a name.

To create a list, the same one as you would do manually by calling "Create List..." from the context menu, you can execute the VBA script below.


Private Sub CreateList()

Range("A1").Select

Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select

Dim NumberOfColumns As Integer
Dim NumberOfRows As Integer
Dim StartCell As Range
Dim EndCell As Range

NumberOfColumns = ActiveSheet.UsedRange.Columns.Count
NumberOfRows = ActiveSheet.UsedRange.Rows.Count

Set StartCell = Cells(1, 1)
Set EndCell = Cells(NumberOfRows, NumberOfColumns)

Dim DataRange As Range
Set DataRange = Range(StartCell, EndCell)

ActiveSheet.ListObjects.Add(xlSrcRange, DataRange, , xlYes).Name = "List1"
Range(StartCell, EndCell).Select
ActiveWorkbook.Names.Add Name:="Data", RefersToR1C1:=DataRange
Range("Data").Select

End Sub


I also give the list the name "Data", which I do to access the data by name afterwords, but this is not required to create the list.

Enjoy :)

Monday, September 21, 2009

Read File Properties with Excel VBA

The VBA script for Excel below will read the 'File Version' from the file properties and will read file name and its version each into a column in a Excel sheet.


Sub getFileProductVersion()

Dim objShell As Shell
Dim objFolder As Folder
Dim objFolderItems As FolderItems
Dim objFolderItem As FolderItem
Dim numberOfFiles As Long
Dim i As Integer
Dim j As Integer

Set objShell = New Shell
Set objFolder = objShell.Namespace("C:\Temp\files")

If (Not objFolder Is Nothing) Then
Set objFolderItems = objFolder.Items()
numberOfFiles = objFolderItems.Count
Range("A1").Select

For i = 0 To numberOfFiles - 1
Set objFolderItem = objFolderItems.Item(i)
ActiveCell.Offset(i, 0) = objFolderItem.Name
ActiveCell.Offset(i, 1) = objFolder.GetDetailsOf(objFolderItem, 39)
Next i

End If

Set objFolder = Nothing
Set objShell = Nothing

End Sub


Enjoy :)

How to specify the browser that should be used in WebTest

In WebTest it is possible to define which browser shall be simulated. Currently WebTest support the following browsers:
  • Firefox3 (or FF3)
  • Firefox2 (or FF2)
  • InternetExplorer6 (or IE6)
  • InternetExplorer7 (or IE7)
To get a more detailed list, have a look at the WebTest config page (http://webtest.canoo.com/webtest/manual/config.html).

As you can see in the simple example below, it is very easy to define the simulated browser for your test:







'Here goes your test code...'







This example is an extract from a browser test of the self test suite of WebTest. For more details, have a look a the self test suite (https://svn.canoo.com/trunk/webtest/selftests/).

Enjoy :)

Wednesday, August 12, 2009

How to create a WebTest project in less than a minute

Assuming you have WebTest installed you can create a WebTest project in less than a minute:

Go to the directory where you want to create the WebTest project


E.g.:

C:\projects


Call the createProject task and provide a name for the project, e.g. myWebTestProject


C:\projects>ant -f %WEBTEST_HOME%\webtest.xml wt.createProject


Change to the project directory


C:\projects>cd myWebTestProject


Call WebTest


C:\projects\myWebTestProject>webtest


Done :)

Tuesday, August 11, 2009

Functional Testing for Joomla! with WebTest

Joomla! is a very popular open-source CMS based on PHP. It is simple to use and makes creating and maintaining Web sites easy for everyone, from total beginners setting up their first site to IT professionals managing enterprise installations.

Like many other projects (not only open-source projects) testing is not the most popular subject. However, testing is very crucial for every project to be able to grow and handle complexity within the project.

Functional testing is one aspect of testing which can focus on the users perspective of using an application.

I started a functional test suite for Joomla! with Canoo WebTest, an open-source tool for automated testing of web applications in a very effective way.

If you would like to have a look at the current state of the work, see here:
Some initial documentation can be found here:
Enjoy :)

Sunday, December 30, 2007

The Screencast Blog

Today I found the screencast blog, which provides a huge number of screencast which mostly show Eclipse features.

Have a look, it's really interesting:
Enjoy!

Regards,
Tomi

Tuesday, November 13, 2007

WebTest Screencast: Data Driven WebTest

We finally made it :)

Marc Guillemot (http://mguillem.wordpress.com/) and I published the new WebTest (http://webtest.canoo.com/) screencast showing Data Driven WebTest based on Google Calculations.

You can find the screencast here:

New screencasts will follow soon...

Enjoy!

Kind regards,
Tomi

Tuesday, November 06, 2007

Groovy Posts & Links

I'm following the Groovy (http://groovy.codehaus.org/) posts and links on http://www.dzone.com/ and http://del.icio.us/. It is amazing, how the number of posts and saved URL's increased over the last couple months.

If you would like to have a look at these, check the following links...

dzone

del.cio.us

Enjoy reading!

Regards,
Tomi

Monday, October 29, 2007

WebTest vs. Selenium

Marc Guillemot compares the features of two popular open source testing tools: WebTest and Selenium!

A must read post! Very interesting!

[..] The maintainability of automated tests depends primarily on the skills of the test authors, but different tools have different features that impact their efficiency. This blog post compares the features of two open source automated web testing tools: Canoo WebTest and Selenium.

http://mguillem.wordpress.com/2007/10/29/webtest-vs-selenium-webtest-wins-13-5/

Enjoy!

Regards,
Tomi

Monday, September 10, 2007

WebTest Screencast: New cast on its way...

Tonight we (Marc Guillemot and myself) were working on a new screencast for WebTest. The new cast will be about data driven web testing.

I'll try to bring the cast online till end of the week, or at least a first beta version :) As soon as I have it published, I'll post a new blog entry.

Regards,
Tomi

Wednesday, August 22, 2007

WebTest Screencast: Creating a first WebTest project

Marc Guillemot (http://mguillem.wordpress.com/) and myself are working on some screencasts to show WebTest capabilities. The first screencast has been announced on the WebTest mailing list:

and can be found here:

We are looking forward to publish a couple more screencasts within the next few months. If there are special features you would like to see in the upcoming screencast, let me know :)

Enjoy!

Regards,
Tomi

Wednesday, August 08, 2007

Dealing with critics?

There is an interesting post on Marc Guillemot's blog:

He's blog entry can be understood in a way, that the lack of XPath can be associated to the lack of test automation experience. If this relation is correct or not is not as interesting as the reaction which has raised based on his entry.

I'm very surprised, how personal this was taken, especially the comment of Neil: http://mguillem.wordpress.com/2007/07/31/xpath-power-2-detect-lack-of-experience/#comment-16. I would have expected more distance to such a statement and more tolerance.

My understanding of Marc's statement is, that the better an XPath expression is (better in the sense of robust), the better the tests are which might be based on the XPath expression. The first XPath statement Marc is quoting:

is not robust at all. If there a small change in the used tables or additional items in the lists, the test will break. If there is a relationship between robust and better, that this statement is not prefered and in this sense, I can understand the statement of Marc very well.

Regards,
Tomi


Thursday, August 02, 2007

Wednesday, December 20, 2006

Groovy in Action

The book "Groovy in Action" is finally out! Have a look, it's worth reading it!

URL:

http://groovy.canoo.com/gina

Description:

Groovy in Action is a comprehensive description of the Groovy programming language, its libraries, and its everyday use. With the release of JSR 241, Groovy has become the second standard language for the Java platform. The book introduces Java developers to the new dynamic features that Groovy brings to this platform.

Enjoy!

Groovy in Action

The book "Groovy in Action" is finally out! Have a look, it's worth reading it!

URL:

http://groovy.canoo.com/gina

Description:

Groovy in Action is a comprehensive description of the Groovy programming language, its libraries, and its everyday use. With the release of JSR 241, Groovy has become the second standard language for the Java platform. The book introduces Java developers to the new dynamic features that Groovy brings to this platform.

Enjoy!

Monday, September 25, 2006

groovy articles on del.icio.us

Since I'm using Groovy in the current project (thanks to Dierk and Marc) I'll start collect articles about groovy...

This might help some other beginners to start with a steeper learning curve as well :)Enjoy!

Read more at del.icio.us/TomiSchuetz...