RE: Implement global variable for Testcase number to execute from excel.

I am using Selenium webdriver with Testng for automation with data driven module where i am reading the testcases data from excel. I have hard coded the row numbers for each test case . If i want to add any cases in the middle again i have to change the numbering of all the cases. So how can i solve this issue.

mallik9292 Train Asked on October 28, 2014 in Selenium WebDriver.
Add Comment
5 Answers

Hi Lakshay,

Thanks for your reply. I have implemented a different way.. So please let me know who to handle this. I am pasting the sample code of one of my function below for a post login page.

Page object code for validate logo

//Function to validate the Logo on Dashboard

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()) {"Logo Found");

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

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

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

}else{"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;

App Module for acessing the function 

public static void Validate_Post_Login(WebDriver driver) throws Exception {
//To sign in to the application

//To validate the logo is displayed on the page.


Suite Framework for execution:


public static void Test_User_Post_Login_A() throws Exception {

Train Answered on October 28, 2014.
Add Comment

Your Answer

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