2

I have a "customer side" and an "administrator side" of a web application. I want to make my tests as solid as possible, so should I be adding new customer(s) on my administrator side before each test and removing them upon completion? I'm concerned that if something fails on the removal, the next run will potentially kick up an error of someone existing when trying to create them again.

Should I be creating them via selenium in the front end? Should I be inserting them into the database for use?

I also have a SOAP API that can be used to addCustomer().

I've used a more data-driven framework in the past for using the likes of Excel databases to house my data, I assume (yet to investigate it, I can handle this with cucumber data tables).

An alternative is to set up the said customers for the test beforehand so that they will always exist in the database, but this seems relatively brittle.

  • Can you run use your own database? If you can do that, you could start your tests by restoring your pre-configured database then running your tests. – Kate Paulk May 18 '17 at 19:09
2

Inserting users through the UI seems like the slowest solution, and I would avoid that unless specifically testing creating users (and I would only test it once). Using existing users can also be a problem if there are different user states that could affect tests (e.g. expired password, locked out, disabled). You really need to have a known state for the account to be in.

On the start of the run, you could tear down and create the db, then insert accounts as needed.

| improve this answer | |
  • And by inserting the accounts directly into the DB, you can test the negative scenarios as well (Locked out, Disabled, expired password) with ease. – Paul Muir May 18 '17 at 17:57
2

Or you can do what I do in one similar test: Check (with selenium) if desired user exist, and add only if it does not. Or delete them and add again, if you want to test also creation (I do not in my situation).

Best way to make your test be more robust is using explicit wait only (don't mix implicit waits), and avoid XPath (use id, name, css locators). If you cannot, get list of elements by tag/link text or class, loop over them and check other attributes to get the one you want.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.