« Zurück zu Selenium

Configuring Selenium Tests

Asset-Tag: selenium

Introduction #

In this tutorial you will learn how to setup your portal so that you can run selenium tests.

Setup #

Before you can run a selenium test you must first edit some of your .xml files and .properties that are found in your build folder. There are three files that you need to edit and/or create in order for your selenium tests to work. So we will just discuss them one by one.

../build/build-test.xml#

In this file you need to edit this particular ant task, prepare-portal-ext-properties. Simply search the file build-test.xml to find this ant task.

What this ant task does is automatically create the portal-ext.properties file, in the ../build/portal-impl/src folder. If you already have this file it will replace whatever is in that file. What that file, portal-ext.properties, does is enable you to use the mysql database and to over-ride the location to which the mysql database will write its data. To choose the location the mysql database will create the folder to hold all of our information we will need to add in the line that is boxed in red. Enter the words liferay.home= and then write the directory to which you want to write your home directory. For example: my home directory is found at L:/home/trunk/liferay. So I added the line liferay.home=L:/home/trunk/liferay to my build-test.xml

One thing you should remember is that whichever branch of liferay you are using should replace the word trunk in the example. For example if you were using the 5.2.x branch the line you add would say:

  • liferay.home=L:/home/5.2.x/liferay

In the 5.1.x branch you would replace the line liferay.home=L:/home/trunk/liferay with:

  • user.home=L:/home/5.1.x

../build/**app.server.liferay.properties**#

The name of this file is specific to each person's computer. For example if the name of your computer is liferay, then you would name this file app.server.liferay.properties. If your computer's name was brian, then you would name this file app.server.brian.properties. If you don't already have this file you will need to open a simple text editor and copy the following into this file:

app.server.parent.dir=L:/sf.net/bundles/trunk
app.server.type=tomcat}}}

The reason you are creating this file is so that when you deploy your build file into your bundles it will know at which directory build them into. Again let's look at the particular line that will determine where your bundles will be written:

This directory, L:/sf.net/bundles/trunk, is where my bundles folder is located. So depending on where you want the ant task to build your tomcat folder, will determine what you set the parent directory to.

../build/build-dist.xml#

The ant task that you are looking to edit is called build-dist-tomcat-5.5. So if you search for that name it will take you to the part of the build file that you need to edit. Here is what the ant task looks like:

First look at the line that is within the red box. You need to add app.server.parent.dir=L:/sf.net/bundles/trunk into that echo command. When you run test-tomcat-5.5 this command will go in and replace whatever is in the file app.server.liferay.properties with what is inside the of the braces.

Now lets look at the line within the blue box. You need to comment out this line of code because this will delete the app.server.liferay.properties file. Which would undo what you just created.

Creating a zip file#

The last thing that you need to do is create a zip file of the tomcat folder in the bundles directory, because the new build-test.xml deletes your old tomcat folder and unzips the one that you have next to it. If you don't have a zip file it will throw an error. So i suggest that whenever you update your tomcat folder always delete your old zip folder and create a new one.

Make sure it is a .zip file and not a .7z file.

You are now ready to run a selenium test.

Running a Selenium Test#

This is very similar to our old method of running selenium tests, you just call test-tomcat-5.5 instead of test-tomcat. The command is now ant -buildfile build-test.xml test-tomcat-5.5. Here is a picture of what it will look like in your command line:

Don't forget to clear your cache, rebuild-mysql, and delete your home when before you start your test. Good luck.

11 Anhänge
40580 Angesehen
Durchschnitt (1 Stimme)
Die durchschnittliche Bewertung ist 2.0 von max. 5 Sternen.
Kommentare