Versions Compared

Key

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

...

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

h2. Create the suite

*{+}TBD{+}*
* Store in a directory under suites
* Call it Suite.html

h2. Create a test

*{+}TBD{+}*
* Click "Record"
* Go through it.
* Click to Stop Recording.

h2. 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)

h2. 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. 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}
If there is more than one Rich Text area on a single page, this may not work. So far, I haven't see that.
!example of rich text editing.png|thumbnail!

h1. Additional information


h2. 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]

...