0
votes

I am working on to automate testing of my web application UI flow using selenium. My project is in asp.net and c#. My question is does selenium provide any option to preset the data before we execute a functional flow through selenium?

Say for example i am automating a book search flow. So before i execute the flow throw selenium automation, i have to be sure that the book i am searching should be in the database already, so when i execute the test, it just works fine. Most importantly when we do this presetup you can reuse this test automation in any environment, dev,qa etc.

So how do we preset the data or set the context for my test to execute without any issue?

1
This isn't Selenium's job. It's your test framework's responsibility to do that. Since you are using C#, I assume you are using MSTest or NUnit, both of which allow you to specify methods to be called when a test fixture/class is first instantiated, when a test method is called, when a test method exits, and when the class/fixture also exists. Google "NUnit test setup" or "MSTest teardown". You'll soon pick it up. Selenium automates browsers, that's it. Time to get your programming hat on!Arran
I am not using Nunit or MsTest. I am using webdriver. In this case how can you do setup and teardown? Now whats the approach you take to preset data for your tests?Alagesan Palani
So what are you using? We need more information about your technology stack that you are usingArran
I use Selenium WebDriver, ASp.Net, c# and excel sheet for providing data for "data driven tests".Alagesan Palani
Ok but what drives the tests? How are you running them? What steps are you taking to actually run those tests? Is it a web page that you navigate to?Arran

1 Answers

0
votes

There are few approaches ..

  • use clean build for each cycle
  • write the testcase such a way that after test scenario its clear the changes made by it
  • write a startup testcase which preset the data and run is as first testcase.