Selenium Workbook #27: CRUD Test Revisit (with Modal)

Client CRUD with Database Reset; Testing modal.

Courtney Zhan


This article is one of the “Selenium Training Workbook” series, a set of bite-sized exercises.

In episode #22, we covered the CRUD (Create/Read/Update/Delete) tests for a Professional in WhenWise. Because automated testers typically write several sets of CRUD tests for an app, it is important to get familiar with writing CRUD tests. This and the next episode serve as a review, along with introducing a few new testing tips.

Learning Objectives

  • Review CRUD Test Design.
  • Use of database reset to help simplify test design.
  • Drive elements in a Modal.
  • Make steps that involve quick JavaScript more stable.

Note: If this exercise takes a bit long, you may skip the refactoring and leave it for the next episode.

Test Design

With CRUD tests, we usually write them together in one test script file. In other words, design as a whole.

There is not much to say about CREATE tests, except make sure the test data is dynamic. For example, you can’t create the same client twice (unless with database reset, which I will explain later).

Then, we can use the newly-created client for READ/UPDATE/DELETE tests. The order is important. After a successful run of the test script, leaving no records in the app.

The above is a general design for CRUD tests. WhenWise sandbox server (for testing) has a built-in database reset feature. By executing the following step before each test case.

  before(:each) do

We don’t worry about side-effects and always can use the seeded data reords. For account , there is one and only one client named “Jet Li”.

We use that for Read/Update/Delete tests.