views:

271

answers:

1

Hi

I used to record tests ion selenium IDE for after export in selenium/rspec formt to run all them with Selenium RC.

Now, I aquire a doubt when I was recording some test of crude operation of data in table with pagination.

For example, supose that I have a table of customers thats can show 10 itens per page and there nineteen customers

in this table.

When I record a test case for verify a creation of a new customer, the new record created (for example the customer Barbosa) will be in the second page and at twentieth

position(last position) of the customers' table. For create a new customer this will be showing in the third page and at first position (pagination with 10 itens per page).

Ok, If I want test to view, edit or delete the twentieth customer (Barbosa) I will need record this test clicking in the link for the second page of customers table

and there click in the link edit, view or delete at the twentieth element of a table. But if more customers are created and after this I run my test suite again

only operation that still works in my test is create a new customer, because view, edit and delete operations are linked with the fixed locations (page 2, twentieth element)

and for crete a new customer the position of this element doesn't matter.For every test new customer created will be show in a new position in the table.

In this kind of situation, there a way for always test the complete CRUD operation in the same record, guaranteed?

Or I need to use another tool?

Thanks so much for any advice

Bruno Moura

+2  A: 

It's best to ensure your tests assume nothing about the dynamic content of your application. The safest way to do this is to clear down the database before you run your tests. This ensures that the application is in a predictable state before you run any tests.

Then you can have a test that creates a user, and knowing that they are the only user can then edit or delete the user.

If you need to test pagination, have a test that creates 10 users after first clearing down the database, check the pagination, create an 11th user and check the pagination again, etc.

If you are unable to clear down the database, you could determine the number of existing users in your test and predict the position of any new users. For example: get the number of the last page of users (for example 3), click the link to open that page, and then get the number of users in that page of results. Add the number of results to 30 (the number of results on previous pages) and you have a total count of users in the application.

Note: There might be easier ways to do this depending on your application.

Dave Hunt