Executing same testcase for multiple data in same session | Selenium Forum
M
Posted on 01/11/2016
Hi,

I am using a Data-driven Framework for my Project. I am using @DataProvider to get the data from Excel. In few of my test cases, I have to execute with huge number of data ( like 300 rows). As per the current script for each data it opens the new browser,logging in and execute the test case. It takes time.

Is there a way I can modify the Framework and log in once and execute all the 300 rows of data one by one in one single session?

I have attached the Base Class, test case and the program for reading data form Excel

Please help.

Thanks,
kannan C

M
Replied on 02/11/2016

Please let me know if you have an update on this.


M
Replied on 03/11/2016

you can execute tests parallely. you will have to change the setting of data provider. [color=#FF0000:1nvkspo7]@DataProvider(parallel = true)[/color:1nvkspo7]


M
Replied on 04/11/2016

Thanks for the update. I used @DataProvider(parallel = true),but it is running all the data at once in separate browser . I want to run one by one.. after completing the 1st row of data then the next row data should be executed.


M
Replied on 04/11/2016

@BeforeTest(){
//initialize webdriver.
}
@test{
//execute test here.
}

@beforetest only runs once before @test.


M
Replied on 06/11/2016

Thanks a lot. It worked out .. All the test data rows run in one session(Same browser) .

But getting only one result for all the test data in Extent report. Previously i get separate result for each test data. Please let me know what kind of change is required here.
Here is the Extent Report program.

import java.io.File;
import java.util.Date;

import com.relevantcodes.extentreports.DisplayOrder;
import com.relevantcodes.extentreports.ExtentReports;

public class ExtentManager {
private static ExtentReports extent;

public static ExtentReports getInstance() {
if (extent == null) {
Date d=new Date();
String fileName=d.toString().replace(":", "_").replace(" ", "_")+".html";
extent = new ExtentReports("D:\\report\\"+fileName, true, DisplayOrder.NEWEST_FIRST);

extent.loadConfig(new File(System.getProperty("user.dir")+"//ReportsConfig.xml"));
// optional
extent.addSystemInfo("Selenium Version", "2.53.0").addSystemInfo(
"Environment", "QA");
}
return extent;
}
}


I use the below statement in each test case class file

@AfterMethod()
public void quit()
{ System.out.println("test1");
rep.endTest(test);
rep.flush();
}

Responsive image

M
Replied on 07/11/2016

Please ignore the above question. I initiated Extent report("test=rep.startTest("Pallet");") in @BeforeTest and also in Test case.
Now each data gets separate result