Login | Register
My pages Projects Community openCollabNet

How to run the demo

In order to view the source code, and run the demo, you need to do a couple of things. If you already have Eclipse and Subversion (or TortoiseSVN, or another Subversion client), you can go directly to 'Download the source code'.

    • Eclipse
    • Subversion
    • Download the source code

Eclipse

Get it from http://www.eclipse.org/downloads/. The Eclipse IDE for Java Developers will do nicely.

Subversion

If you are on a Windows platform, the download TortoiseSVN from http://tortoisesvn.tigris.org/, this client will integrate in the Explorer, and works very well.

Else, get Subversion from http://subversion.tigris.org/, which works as a traditional command line client.

Download the source code for the demo

If you want to get the code using subversion, open a terminal, and go to a empty folder. Type the following:

$> svn export http://mbt.tigris.org/svn/mbt/trunk/demo demo

This will fetch the demo project, and place it in a folder called demo.

Open and run the project in Eclipse

  1. Start Eclipse, and choose as workspace, the folder in which the demo project was exported to.
  2. From the menu, select File -> New -> Java Project.
  3. Select the radio button Create project from existing code, and select as Directory, the folder demo.
    In Project name, type demo.
    Click Finish.

    Create java project from existing source

  4. When the java perspective is selected in Eclipse, you should see something that looks like this:

    The Demo project is loaded

  5. In Package Explorer, expand the tree so you can see the UC01.java file. Double-click the file, and it will open.
    Go to the e_init() method in that file. Now, you have to change things a bit regarding to what platform you are running.
    Windows: Comment the line 84, an un-comment the line 87.
    Linux: Comment the line 87, an un-comment the line 84. Also, you have to type the absolute path to firefox-bin.
    See DefaultSelenium documentation for details.

    Java file UC01.java


  6. Now, everthing is ready to run! Right-click the UC01.java file in the Package Explorer. Select Run As -> JUnit Test.

    Run the demo

  7. The test will start. If everything works, you will see Firefox being launch by Selenium. The test will click on links, search books etc. When the test is finished after about a minute, the JUint progress bar will, hopefully, be green.

    Success after a test run

Where are the results?

The results are stored in a log file. The default location is logs/mbt.log. The properites of the log file is controlled by the mbt.properties file. A typical log file result can look like this:

2008-02-02 10:48:22,528 [main] INFO  - Done merging
2008-02-02 10:48:22,798 [main] INFO - Step: 1 Navigate: e_init
2008-02-02 10:48:22,798 [main] INFO - Edge: e_init
2008-02-02 10:48:22,912 [main] INFO - Vertex: v_BrowserStopped
2008-02-02 10:48:22,994 [main] INFO - Step: 2 Navigate: e_StartBrowser
2008-02-02 10:48:22,994 [main] INFO - Edge: e_StartBrowser
2008-02-02 10:48:28,187 [main] INFO - Vertex: v_BrowserStarted
2008-02-02 10:48:28,245 [main] INFO - Found browser with title:
2008-02-02 10:48:28,245 [main] INFO - Step: 3 Navigate: e_EnterBaseURL
2008-02-02 10:48:28,245 [main] INFO - Edge: e_EnterBaseURL
2008-02-02 10:48:31,967 [main] INFO - Vertex: v_BaseURL
2008-02-02 10:48:32,028 [main] INFO - Step: 4 Navigate: e_SearchBook
2008-02-02 10:48:32,028 [main] INFO - Edge: e_SearchBook
2008-02-02 10:48:32,177 [main] INFO - Vertex: v_SearchResult
2008-02-02 10:48:35,806 [main] INFO - Step: 5 Navigate: e_ShoppingCart
2008-02-02 10:48:35,806 [main] INFO - Edge: e_ShoppingCart
2008-02-02 10:48:35,902 [main] INFO - Vertex: v_ShoppingCart
2008-02-02 10:48:37,279 [main] INFO - Step: 6 Navigate: e_SearchBook
2008-02-02 10:48:37,279 [main] INFO - Edge: e_SearchBook
2008-02-02 10:48:37,412 [main] INFO - Vertex: v_SearchResult
2008-02-02 10:48:40,521 [main] INFO - Step: 7 Navigate: e_ClickBook
2008-02-02 10:48:40,521 [main] INFO - Edge: e_ClickBook
2008-02-02 10:48:40,657 [main] INFO - Vertex: v_BookInformation
2008-02-02 10:48:47,002 [main] INFO - Step: 8 Navigate: e_SearchBook
2008-02-02 10:48:47,002 [main] INFO - Edge: e_SearchBook
2008-02-02 10:48:47,179 [main] INFO - Vertex: v_SearchResult
2008-02-02 10:48:50,761 [main] INFO - Step: 9 Navigate: e_ClickBook
2008-02-02 10:48:50,761 [main] INFO - Edge: e_ClickBook
2008-02-02 10:48:50,916 [main] INFO - Vertex: v_BookInformation
2008-02-02 10:48:56,777 [main] INFO - Step: 10 Navigate: e_AddBookToCart
2008-02-02 10:48:56,777 [main] INFO - Edge: e_AddBookToCart
2008-02-02 10:48:56,961 [main] INFO - Vertex: v_OtherBoughtBooks
2008-02-02 10:48:59,184 [main] INFO - Step: 11 Navigate: e_SearchBook
2008-02-02 10:48:59,184 [main] INFO - Edge: e_SearchBook
2008-02-02 10:48:59,327 [main] INFO - Vertex: v_SearchResult
2008-02-02 10:49:03,137 [main] INFO - Step: 12 Navigate: e_ClickBook
2008-02-02 10:49:03,138 [main] INFO - Edge: e_ClickBook
2008-02-02 10:49:03,260 [main] INFO - Vertex: v_BookInformation
2008-02-02 10:49:09,268 [main] INFO - Step: 13 Navigate: e_AddBookToCart
2008-02-02 10:49:09,268 [main] INFO - Edge: e_AddBookToCart
2008-02-02 10:49:09,454 [main] INFO - Vertex: v_OtherBoughtBooks
2008-02-02 10:49:11,509 [main] INFO - Step: 14 Navigate: e_ShoppingCart
2008-02-02 10:49:11,509 [main] INFO - Edge: e_ShoppingCart
2008-02-02 10:49:11,581 [main] INFO - Vertex: v_ShoppingCart
2008-02-02 10:49:13,227 [main] INFO - Step: 15 Navigate: e_SearchBook
2008-02-02 10:49:13,227 [main] INFO - Edge: e_SearchBook
2008-02-02 10:49:13,337 [main] INFO - Vertex: v_SearchResult
2008-02-02 10:49:16,757 [main] INFO - Step: 16 Navigate: e_ClickBook
2008-02-02 10:49:16,757 [main] INFO - Edge: e_ClickBook
2008-02-02 10:49:16,859 [main] INFO - Vertex: v_BookInformation
2008-02-02 10:49:22,726 [main] INFO - Step: 17 Navigate: e_ShoppingCart
2008-02-02 10:49:22,726 [main] INFO - Edge: e_ShoppingCart
2008-02-02 10:49:22,788 [main] INFO - Vertex: v_ShoppingCart

In the log file, it is logged how the test walked through the model. If an error occurs, it is easy to follow the execution up to the point of failure.

What if I'm behind a proxy?

Then you have to tell selenium! It is done by passing (to the jvm):

-Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=1234

or, if you need to pass the credentials

-Dhttp.proxyHost=myproxy.com -Dhttp.proxyPort=1234 -Dhttp.proxyUser=joe -Dhttp.proxyPassword=example

You do this by selecting the Open Run Dialog..., which will open:

Proxy injection

Add the arguments in the box VM Arguments.

Please note!

But please not that there is a bug in Selenium: http://forums.openqa.org/thread.jspa?messageID=10909, I made it work by downloading the latest version from: http://selenium-rc.openqa.org/download.jsp, (Version latest nightly latest nightly build - unstable).