CSci 4657 Lab 4. Due Wednesday, February 16 at 11:59pm
Goals of this lab:
- Introduction to Selenium IDE testing and test-driven development in
javascript.
- Get practice with javascript regular expressions.
- Get more practice with forms and DOM.
You should work in pairs if at all possible. I
recommend Ping
Pong Programming: one person writes a test, the other person
makes it pass and writes the next test, then the person who wrote the
previous test makes it
pass, and so on. Refactoring of both the tests and the code is done as
needed.
Software needed
Lab tasks
(40 points)
You will be working with the following form and validation
code: the form. You are
given one Selenium
test as a starting point.
Your task is to extend the functionality and to add validation for
more conditions. All your code should be tested using Selenium IDE:
write a test for every condition that you are validating, perhaps in
combination with other conditions.
Specifically, you have to implement the following:
- Add testing code to checking that "food" field is not empty.
- Add a test for checking that at least one season is clicked, but not
all, then implement the check and make the test pass.
- Add a test to check that correct user inputs are preserved when
errors are reported, and the incorrect ones are removed. Add the
corresponding functionality.
- Add a test to check that after a successful submission all error
messages are removed and all highlighted fields are back to normal
formatting. Then make the test pass.
- Add a test for the case when the user
submits the form unsuccessfully twice to make sure that the second time
only relevant error messages are signaled. Make the test pass.
- Change the name validation so that only English letters, spaces,
dashes, apostophes,
and commas are allowed, and the name starts with a letter. Again,
start by writing tests, and then make them pass.
- Add a phone number field that accepts a 10-digit phone number in
the following format: the area code may or may not be surrounded by
parentheses, the other allowed separators are a space, a dash, and
a dot. A combination of those is OK. However, parentheses are not
allowed in any places other than around the area code (note that
this is still somewhat ambiguous, your tests and comments should
clarify your interpretation of the format). The field is
required to be non-empty. Write tests
for validation of the phone number field and make them pass. make
suure your previous tests still pass (or if not, modify them
appropriately).
You may have more than one test per condition, or break tests down
into smaller sub-tests. Give your tests meaningful names and add
comments as needed. Make sure to rerun the entire test suite after
every change.
The quality of your javascript code will be graded: refactor as
appropriate!
What to submit.
Send me (CC your partner(s)) all your files developed for this lab.
This page is a part of CSci 4657
course web site.