RE: [webdriver] Webdriver -How to delete test data after end of each test run

590 views
Skip to first unread message

Peter Gale

unread,
Sep 21, 2012, 1:46:19 PM9/21/12
to webd...@googlegroups.com
You could make a direct connection to your database from java and execute SQL to delete any instance of the record you are about to create through a browser controlled by WebDriver.

Unless your AUT exposes functionality through the browser to delete records, it is not somethign you can do with WebDriver.

You'll need the connection details for your database so you should ask your database guys about that and how to interact with it in the way you want.

I would also speak to your test manager about the strategy for initialiing environments prior to the executon of test runs.


Date: Thu, 20 Sep 2012 18:41:55 -0700
From: ash...@gmail.com
To: webd...@googlegroups.com
Subject: [webdriver] Webdriver -How to delete test data after end of each test run

Hi ,

I using webdriver with java ( using jbehave BDD framework)

I have  a test which is kinda client registration ( filling out a form and saving to the database) 

I can't run the test with the same data again because it is going to create duplicate records in the database.
How do i make my webdriver test to clean the data at the end of each run ( or before a new test run) ?

The given condition i specify the client data that needs to be registered  like the below

|client name|DOB|
|John|13/10/1978|

Any help is much appreciated

Thanks

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/ecrfPRskf5UJ.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

pna...@gmail.com

unread,
Sep 21, 2012, 2:00:25 PM9/21/12
to webd...@googlegroups.com
If you can clean the database records as part of the teardown, you don't have to worry about duplicate records.

Also, this is not something webdriver can help you with. Read about Jdbc and see how you can connect to the DB and build some sql statements as part of the test to delete the records your test would insert.

Sent from my BlackBerry® wireless device

From: Gopi Ganesasundaram <ash...@gmail.com>
Date: Thu, 20 Sep 2012 18:41:55 -0700 (PDT)

Bill Ross

unread,
Sep 21, 2012, 7:42:25 PM9/21/12
to webd...@googlegroups.com
My approach to the distinct-user problem is to generate random users
so I don't have to delete old ones. So user names can be like xikh6kj_user.

Bill

Peter Gale <peterjef...@hotmail.co.uk> wrote:

>
> You could make a direct connection to your database from java and execute SQL to delete any instance of the record you are about to create through a browser controlled by WebDriver.
>
> Unless your AUT exposes functionality through the browser to delete records, it is not somethign you can do with WebDriver.
>
> You'll need the connection details for your database so you should ask your database guys about that and how to interact with it in the way you want.
>
> I would also speak to your test manager about the strategy for initialiing environments prior to the executon of test runs.
>
> Date: Thu, 20 Sep 2012 18:41:55 -0700
> From: ash...@gmail.com
> To: webd...@googlegroups.com
> Subject: [webdriver] Webdriver -How to delete test data after end of each test run
>
> Hi ,
> I using webdriver with java ( using jbehave BDD framework)
> I have a test which is kinda client registration ( filling out a form and saving to the database)
> I can't run the test with the same data again because it is going to create duplicate records in the database.How do i make my webdriver test to clean the data at the end of each run ( or before a new test run) ?

MattD

unread,
Jan 23, 2013, 9:29:37 AM1/23/13
to webd...@googlegroups.com
This approach is almost necessary if you plan on running these tests in parallel on a grid.  If you are using hard coded accounts the test may not work predictably when run in parallel since tests may be writing data to same account at the same time.

I ran into this problem but unfortunately I am unable to create distinct users programatically as we rely on another service (not controlled by our team) for account creation and it uses CAPTCHA for verification.

Andrew Fowler

unread,
Jan 23, 2013, 11:19:58 AM1/23/13
to webd...@googlegroups.com
In my tests I have a 'dirtiesData' flag which gets set for the relevant tests, and then run a SQL cleanup routine in teardown where necessary.

Like someone said though, this would probably be more complicated if you're parallelising tests.

Bill Ross

unread,
Jan 24, 2013, 6:06:14 PM1/24/13
to webd...@googlegroups.com
Ideally you'd have that team provide a CAPTCA back door that only
works for hosts in your test env, e.g. when the typed key is some
arbitrary value, CAPTCHA accepts it. Or if you're white box enough,
create the user directly in the dbase.

Bill
> > > From: ash...@gmail.com <javascript:>
> > > To: webd...@googlegroups.com <javascript:>
> > > Subject: [webdriver] Webdriver -How to delete test data after end of
> > each test run
> > >
> > > Hi ,
> > > I using webdriver with java ( using jbehave BDD framework)
> > > I have a test which is kinda client registration ( filling out a form
> > and saving to the database)
> > > I can't run the test with the same data again because it is going to
> > create duplicate records in the database.How do i make my webdriver test to
> > clean the data at the end of each run ( or before a new test run) ?
> > > The given condition i specify the client data that needs to be
> > registered like the below
> > >
> > > |client name|DOB||John|13/10/1978|
> > > Any help is much appreciated
> > > Thanks
> > >
> > >
> > >
> > > --
> > >
> > > You received this message because you are subscribed to the Google
> > Groups "webdriver" group.
> > >
> > > To view this discussion on the web visit
> > https://groups.google.com/d/msg/webdriver/-/ecrfPRskf5UJ.
> > >
> > > To post to this group, send email to webd...@googlegroups.com<javascript:>.
> >
> > >
> > > To unsubscribe from this group, send email to
> > webdriver+...@googlegroups.com <javascript:>.
> > >
> > >
> > > For more options, visit this group at
> > http://groups.google.com/group/webdriver?hl=en.
> > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> > Groups "webdriver" group.
> > > To post to this group, send email to webd...@googlegroups.com<javascript:>.
> >
> > > To unsubscribe from this group, send email to
> > webdriver+...@googlegroups.com <javascript:>.
> > > For more options, visit this group at
> > http://groups.google.com/group/webdriver?hl=en.
> > >
> >
>
> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/webdriver/-/l_Gn3g1WCYEJ.
Reply all
Reply to author
Forward
0 new messages