What is an efficient way to write automated end to end user scenarios?

1.6k Views Asked by At

When automating user scenarios, we typically cover an end-to-end user flow. Unit testing recommends that each test method should be independant and only test one thing. But things are different in system acceptance testing, as we have to cover a user flow through the application.

Consider an ecommerce application where the user journey typically follows the below steps:

1 - visit homepage
2 - search for a product
3 - select the product
4 - add the product to cart
5 - click checkout
6 - sign in
7 - enter peyment details
8 - submit order
9 - wait for confirmation

Now each of these steps need to be verified as we flow through the user journey. So, there is dependency in test methods, e.g. step 3 depends on step 2 which breaks unit testing practice. Also if we put all steps in one test method it is not easy to detect what went wrong if the test failed. And if we wanted to isolate each test method so they are independant of each other, we have to repeat the initial steps over and over again.

What I have done in the past is to use TestNG to provide this dependency on previous test methods. I want to know how to handle user journeys in your testing.

How do you handle user journeys in your testing?

2

There are 2 best solutions below

3
On

Selenium is good for this. It has a Firefox plugin that allows you to "record" an end-to-end test that you perform in the browser, which can be played back later. You can also modify/hand-code tests. There's also support for modifying and running the tests in various languages (eg, we use C#), so you can code various logic and conditions into the test flow.

Looking at your test steps, I think it should be an elementary implementation (in theory -- in practice you may need some tweaking to make sure the HTML element selectors are correct every run).

  1. open URL
  2. enter text in a text box and click a button
  3. click a link
  4. click a button
  5. click a button
  6. enter text in two text boxes and click a button
  7. enter text in various text boxes
  8. click a button
  9. (code integration, check for email?)
0
On

Chromium Browser Automation, also good sollution. You can also check for documentation and tutorials in Chromium Browser Automation web site: http://chrome-automation.com/ .