I am doing automation testing of web browsers using selenium and the test includes that i create users, add personal details, approve, recommend and the likes. how do I clean up these data that has been saved so that each time I run selenium test it starts on a clean state and the test passes. I haven't tried any method because I don't know what to do and that is why i am here to ask P.S: the language i am using to write my selenium test is C#.
-
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.– Community BotCommented May 17 at 10:45
-
Complementing the point of the Community bot, note that Selenium is simply a browser driver - it operates on web page only. Your Users and other details are probably saved/manipulated in services in the backend. I suggest for you to detail their APIs, implementation details (specially DBs) and architecture. In this way, people can suggest tools and approach to clean this data.– João FariasCommented May 20 at 6:42
Add a comment
|
1 Answer
I assume that your tests are failing because the application does not allow duplicate data or the same data for the second time. To cope up with this you can use any of the following methods
- Teardown: Use a teardown method to delete or reset the data created during the test execution (This is the widely used method as we can use the same set of data for every execution as the data created in the previous test execution gets deleted by this teardown method)
- Uniqueness: You can ensure that each of the provided test data is unique by appending it with a unique identifier like timestamp as below
firstName + DateTime.Now.ToString("yyyyMMddHHmmssfff")
. This would also help us in cleaning the data that was created during a specific interval of time.