Execute testcases by reading the data from excel row and colum in selenium with out hardcoding row col values

I am using datadriven framework for executing the testcases using selenium. i am reading the data from excel and writing the result to it.

The below is the sample function

First Test case


public static WebElement lnk_Home_Logo(WebDriver driver) throws Exception{

Log.startTestCase(ExcelUtils.getCellData(1,4));

if(driver.findElement(By.xpath("/html/body/div/div/div/div[2]/a/img")).isDisplayed()) {

Log.info("Logo Found");

ExcelUtils.setCellData1("Pass", 1,2);

ExcelUtils.setCellData1("Logo Found", 1,3);

System.out.println("Logo is displayed");

}else{

Log.info("Logo Not Found");

ExcelUtils.setCellData1("Fail", 1,2);

ExcelUtils.setCellData1("Logo not Found", 1,3);

System.out.println("Logo is not found");
}

Log.endTestCase("TestCase End");

return element;


So i have hardcoded in the same way for the remaining cases. The problem is if i want to add any case in the middle i have to again change the number series for all. Also when there is many row of test data.

So how to rectify this problem. How can I reuse the code like pageObjects in Hybrid framework like tutorials in toolsqa. Please help. Thanks.

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.