Datadriven testing

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Datadriven testing

Sudheer Reddy T
Hi Tarun,

Can you please guide me how we can do data driven testing in selenium 2.0.I want to use Junit and Data Driven frameworks.
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven testing

softwaretestingforum
Administrator
Hi Sudheer,

Though I have not used Junit myself, I suggest you to see this guide -

http://weblogs.java.net/blog/johnsmart/archive/2009/11/28/data-driven-tests-junit-4-and-excel
~ seleniumtests.com
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven testing

Illusion0Reality
In reply to this post by Sudheer Reddy T
I used junit and data driven.
Though, all this can't be explained here itself, I will provide some brief description
Mostly used annotations are @Test, @After and @Ignore.
Please refer to web.

We need to attach Junit jar file and import all classes.
We have to have driver script from which we call all other Page related classes (Page Objects). In this page related classes we should have page related functions.
From XLS or flat file, the test data should be fetched and stored into some variables / arrays.

Based on some logic that specific page related object should be created / or those static methods should be called.

E.g.:

For, Login Page, I have 3 fields to interact with.

So, I have a class, and one method to do the login task.
---------------------
public class Login{
public loginfunction(String testdata)
throws Exception
{
driver.findElement(By.id("UserName")).sendKeys(testdata);

//after entering the data, the fail or pass result maybe written to flat file / XLS
av.writePOI(passflag,pagename,fnamearr[rc],fnamearr[rc+1],excelrc,"c:\\resultsall.xls",passdescription)
break;
}
}
----------------- code ends here

I create Login class's object like this:
Login loginobj = new Login()


I call the method to enter test data in the user name field. In the testdata variable, the value ="Michael"
loginobj.loginfunction(testdata)

So, the test data will be entered using the method above.

Data driven works like this.
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven testing

Sudheer Reddy T
Thanks a lot
Reply | Threaded
Open this post in threaded view
|

Re: Datadriven testing

Sudheer Reddy T
In reply to this post by Illusion0Reality
Thanks a lot tarun