Access Keys:
Skip to content (Access Key - 0)
Log in (Access Key - 5)



Toggle Sidebar

Testing non HTML media

Molybdenum is based on Selenium. Selenium is focused on testing (X)HTML pages.
Too allow the test of other media than HTML, Molybdenum goes the following way:

  1. download the media file
  2. call an external helper application to convert the media to HTML or text
  3. load the result into a browser window
  4. use regular Molybdenum functionality to apply checks on the result

Limitations

Currently. Molybdenum supports the configuration for only one helper application. There is a feature request for adding the possibility to configure more than one helper application.
The command processResource needs Firefox version 3 or higher.

Testing PDF

A well known tool to convert PDF to text or HTML are Xpdf or Poppler.
The Software above is available for variuos operating systems. On most Linux systems, the commandline tools are preinstalled.
As an helper application for Molybdenum we want to use the command line tool pdftotext.
We need to know the full path to the tool. Under Wi**ows you would know, where you installed the tool. Under Un*x systems, try the following command, which will give you the full path as output:

which pdftotext

With the information of the full path of the tool we can start configuring Molybdenum. Open the Preferences Window by navigating to Edit-->Preferences

Configuration

Key
Used to identify the helper application to be called from the command processResource
Commandline
The commandline to be used starting with the full path of the tool and including the arguments. $1 is the placeholder for the inputfile to be read by the tool and $2 is the placeholder for the outputfile produced by the tool. Both placeholders will be filled by Molybdenum before calling the tool.
Result File Extension
The file extension appended to the output file by Molybdenum. This will give the browser a hint about the mimetype of the file so it is displayed the correct manner.

Example commandline for a Un*x system:

/usr/bin/pdftotext -layout -htmlmeta  $1 $2

Test commands

First, we have to determine the url of the pdf file for download. Assuming the pdf file is reachable via link like the following:

<a id="pdfdownload" href="my.pdf">PDF download</a>

The link can be stored in a variable with the following command:

storeAttribute | id=pdfdownload@href | pdflink

Now, we can pass the link to the command processResource

processResource | ${pdflink} | pdf2text

where the first argument is the link and second one is the key of the helper application configured beforehand.
The command will download the resource, pass the downloaded file to the helper application and store the result file on the local filesystem. The file stored will be opened in a browsertab afterwards.
The newly opened browserwindow will be registered under the id _molybdenum_processedresource_.

Now we can use the following command to select this window and to perform checks on it.

selectWindow | molybdenum_processedresource

Checks can be performed now like that:

assertTextPresent | My PDF content

We can close the window and switch back to the main test window at the end:

close
selectWindow| null

The complete command sequence looks like this:

storeAttribute | id=pdfdownload@href | pdflink
processResource | ${pdflink} | pdf2text
selectWindow | _molybdenum_processedresource_
assertTextPresent | My PDF content
close
selectWindow | null
last edited on Apr 28, 2009 09:25
Adaptavist Theme Builder Powered by Atlassian Confluence