Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

So far, the test model is very simple. It contains 4 user accounts, so you will not need to create them in your tests. The model records that each of the users has already logged in, so you will not need to do a first-time password change in your tests.

UseremailPasswordRole
testAdmintestAdmin@cornell.eduPasswordsystem administrator
johnCuratorjohnCurator@cornell.eduPasswordcurator
sallyEditorsallyEditor@cornell.eduPasswordeditor
joeUserjoeUser@cornell.eduPasswordself-editor

Prepare your working environment

...

You will need to have a VIVO development area on your computer, along with things like Java and Tomcat. This document won't tell you how to create a development area.

In these instructions,

the term [VIVO] will refer to the top directory of VIVO source code fetched from the GitHub,

the term [VIVO_HOME] will refer to the top directory of your Vivo development area, and
the term [VITRO_HOME] will refer to the top directory of your Vitro development area.
(For some developers, this will be within the Vivo area, but for most developers it will be a separate area).

Clean your

...

database

As you develop the acceptance tests, you will frequently want to clean your MySQL database, so it will contain exactly the same data each time the tests are run. It may be helpful to create a script that will do this. Create You should create a script file, called something like cleanMySQLlike cleanDatabase.sh (Unix) or cleanMySQLcleanDatabase.bat (Windows)..

If you are using TDB storage, it is necessary to reinitialize the content of the VIVO triplestore. To do this it is necessary to delete the directories rdf, tdbContentModels, tdbModels contained in[VIVO_HOME].

Copy the text below into the script. Substitute the VIVO_HOME with the path to the top directory of your Vivo development area. Moreover, check the path to the tdbContentTripleSource directory in [VIVO_HOME]/config/applicationSetup.n3 


Code Block
cd $VIVO_HOME
rm -r rdf
rm -r tdbContentModels
rm -r tdbModels


If you are using SDB storage preserved in MySQL, copy the text below Copy this text into the script. This should all go on a single line:

...

Substitute the user name, password and database name, taking the appropriate values from your runtime.properties file (deploy.properties fileprior to version 1.6). So, for example, on my system, the script would look like this:

...

Stop Tomcat if it is running, and run this script to clean the MySQL database. The next time you start VIVO, you may need to allow some extra time for it to load the default model data files into the database.

...

Copy the test model data file

from here:
[VITRO_HOMEVIVO]/utilities/testrunner/src/edu/cornell/mannlib/vitro/utilities/testrunner/selenium/test-user-model.owl
to here:
[VIVO_HOME]/rdf/auth/firsttime/test-user-model.owl

Build the application

Run ant deploy Rebuild VIVO (mvn install -s example-settings.xml) and start Tomcat.

Confirm that the test data is available

...

Start Firefox, and go to [http://seleniumhq.org/download/], where you will see a link to download the most recent version of Selenium IDE. Click on that link, and allow Firefox to install Selenium and to restart.

 

Note: previous versions of this page included instructions about installing local customizations to Selenium. Those customizations are no longer used, and should not be installed.

...

In the Selenium window, click this button: !ScreenShot007.jpg! Image Added

What you should see

...

You should see each step turn yellow as Selenium attempts it, and then turn green when it is successful. The {{The Log}} panel will record each step of each test, along with any error messages.

When the suite is finished, all of the tests should be green. Something like this:!ScreenShot071.jpg|thumbnail!

Image Added

Creating tests

...

Plan to write a suite of tests.

Decide what functions you want to exercise.

Break the functions into separate tests.

Decide on a name for the suite, and a name for each test.

Know what steps you will perform before you start to record -- It helps to rehearse.

Remember that you can easily throw the test away and record again.h3. *assert* versus *verify*

assert versus verify

Selenium allows your tests to *to verify* certain conditions, or to *to assert* those conditions.* If *

  • If assert

...

  • fails, the test stops executing immediately.

...

  • If verify

...

  • fails, the test continues to run, but will be marked as a failure.

You can use *use verify* to get more information about how the test failed. For example, you might want to verify 5 separate text fields to see which ones are correct. If you used *used assert* instead, the test would stop after the first failure.h3.

Saving tests

Each test suite should be saved in its own folder, under {{\[VIVO_HOME\]/utilities/acceptance-tests/suites}}

You can choose any meaningful name for the suite folder. For example {{user-management}}, or {{self-editing}}.

The suite itself must be named {{named Suite.html}}

The tests must all be stored in the suite folder. Give each one a meaningful name. For example: {{ CreateNewUser.html}}h2.

Open Selenium

*{+}TBD{+}**

  • Set the base URL

...

Create the suite

*{+}TBD{+}**

  • Store in a directory under suites

...

  • Call it Suite.html

...

Create a test

*{+}TBD{+}**

  • Click "Record"

...

  • Go through it.

...

  • Click to Stop Recording.

...

Edit the test

*{+}TBD{+}**

  • Add comments

...

  • Change the starting URL

...

  • Sometimes need to change "click" command to "clickAndWait"

...

  • Sometimes need to add "wait" command

...

  • Add other assertions (verifyElementNotPresent)

...

Confirm that it works

*{+}TBD{+}*h2.

Commit to Subversion

*{+}TBD{+}*h1.

Tips for working with Selenium

*{+}TBD{+}*

How to open the Test Suite panel (not immediately obvious): !OpenSuitepanel.jpg|thumbnail!
h1.

Image Added

Tips for writing tests

*Auto Logout* \\ 
If your test begins by logging in, put a {{deleteAllVisibleCookies}} command right at the beginning. This makes sure that you are not logged in to VIVO. If an earlier test failed and didn't logging out, this will prevent your test from failing on the login attempt.*

Default selection* \\
If a form includes a selection box which defaults to the value you want, it might make sense to explicitly select that value in the test anyway. Then, if the default value changes, the test will still work.

*Links with the same name* \\
Be sure that the locators in the tests are specific enough. An instruction to click on {{link=Add}} probably won't work if there are several links named "Add" on the page. You may need to use a more elaborate locator, like {{//div\[@id='oprop-core-linkedAuthor'\]/a}}*

Entering "Rich Text"* \\ 
When you enter text into a "Rich Text Editing" area, also known as a TinyMCE frame (see image below), Selenium will not record your input. You must manually insert a command into the test, like this:{noformat}
type    tinymce    This is my text
{noformat}

Code Block
type    tinymce    This is my text

If there is more than one Rich Text area on a single page, this may not work. So far, I haven't see seen that.!example of rich text editing.png|thumbnail!
h1.

Image Added

Additional information

...

Selenium IDE

This is the definitive introduction to the IDE. Lots of good stuff here. Please remember to install from your VIVO work area, and not from the download.

[Selenium IDE documentation | http://seleniumhq.org/docs/03_selenium_ide.html]

Similarly, this is the definitive reference to the Selenium command language (Selenese). Also plenty of detail about locating elements within a page.

[Selenium Commands | http://seleniumhq.org/docs/04_selenese_commands.html]h2.

XPath:

For more powerful means of specifying elements or[

XPath tutorial with copious examples | http://www.zvon.org/xxl/XPathTutorial/General/ examples.html]

[More examples | http://msdn.microsoft.com/en-us/library/ms256086.aspx]

[Another XPath tutorial | http://www.w3schools.com/XPath/default.asp]

[A quick reference card | http://www.xml.dvint.com/docs/XPath-2.pdf]

[Some tips for using XPath | http://www.xml.com/lpt/a/1018