Selenium Workbook #28: CRUD Test Revisit (without Database Reset)

Client CRUD without Database Reset.

Courtney Zhan

--

This article is one of the “Selenium Training Workbook” series, a set of bite-sized exercises. While each exercise is independent, it may require knowledge and practices covered in previous episodes.

In the previous episode, we created CRUD Client tests for WhenWise with database reset (my father calls it ‘The Simpsons Pattern’). However, 99.9+% web apps won’t have this database reset utility implemented. This exercise shows a typical set of CRUD tests, without database reset.

Learning Objectives

  • Review CRUD Test Design, without database reset.
  • Review refactoring
  • Variables and Scope
  • Global Variables

Test Design

We still design four test cases as a whole, putting them into a single test script file.

  • CREATE
    We need to create a unique client every single time. This can be achieved using dynamicly-generated names and emails.
  • READ
    Use the new client freshly created by the above test case. This means We need to remember the new client name.
  • UPDATE and DELETE
    These two actually are similar to the READ — using the newly created client. DELETE must be the last test case in the script.

Test Data:

Site URL: https://whenwise.agileway.net
Login: driving@biz.com
Password: test01

Tasks

Task 1: Using Dynamic Data for CREATE

To ensure uniqueness within the system, each client must have a distinct email address. This means it has to be dynamically assigned. Thanks to Faker, it is quite easy to do so.

    first_name = Faker::Name.first_name
last_name = Faker::Name.last_name
email = Faker::Internet.email
mobile_phone = "04" + Faker::Number.decimal_part(digits: 8)

For now, you just treat a variable as a storage box that saves the data, which you can retieve later.

--

--