How can i use dataprovider in below case?or sm other way | Selenium Forum
M
Posted on 17/06/2016
HI Ashish,

I have a below scenario.

I have POM framework in my project
flow is something like this login->entercity->enterdate->some specific operation->save->close browser

Now i want to run above scenario with 5 different cities

right now , i am using only one city

I tried using dataprovider but after login in 2nd test case I am providing city1 and immediately after that testng taking city 2 which is happening something wrong


Can you please suggest how can it be done?

M
Replied on 17/06/2016

in excel sheet make 5 rows of data one for each city.

and then data provider should run your test 5 times.


M
Replied on 28/06/2016

I tried using that but what happens is

I have 5 tests in one class(java file) smthing like this
class XYZ

{
@test(priority=1)
public void login()
{
}

@test(priority=2,dataprovider="abc",dataproviderClass=xyz.class)
public void enercity()
{
}

@test(priority=3)
public void save()
{
}


@test(priority=4)
public void close()
{
}

}

I am running one class as a end to end individual flow ,now in above case , testng takes one city and immediately after that takes 2nd city and before completing all full flow it takes all cities .I am expecting testng to run full flow as per priprity defined and then next data from dataprovider but it does happen in that way


M
Replied on 28/06/2016

you can do it like this.
please watch the testng module before proceeding.

class XYZ

{
@beforemethod
public void login()
{
}

@test(priority=2,dataprovider="abc",dataproviderClass=xyz.class)
public void enercity()
{
}

@aftermethod
public void save()
{
}


@aftertest
public void close()
{
}

}


M
Replied on 05/07/2016

hi ashish..it does not work in dat way..I will mail you my code and structure