Firstly I would like to point out that I'm a beginner when it comes to selenium so I apologise if this is not presented appropriately.
I would like to incorporate data driven testing into my ui_automation project. Our product validates data and returns various information about said data.
I have incorporated both csv and excel utilities to achieve this and currently have a @test that loops through 12 possible login attempts and then asserts against the result in the excel sheet (if login was successful or not). Now all the tests pass but it treats all the individual tests (the different rows of possible combinations and assertions) as one big test.
My question is I could potentially have hundreds of rows of data going into similar loops later on, should one fail the test case fails as a whole (which is not an issue) but how do you determine which record it was that failed so it can be quickly debugged or raised as a defect?
I was thinking of maybe an event listener that waits for assertions fail and then I could produce some sort of Log message but I dont know if this is effective and more to the point WebDriverEventListener does not contain a method for 'assertionFail' so that felt like a brickwall.
It would be great if there was a magic wand for this but I was just hoping there were some valid solutions you guys had that at least let me know it was possible.
I have included my loop code basically I want it to treat each loop as a sub test of the main test if its possible and get some sort of acknowledgement as to which test fails that is readable to a fellow QA team member that will view things from a high level point of view.
@Test
public void loginValidationTest() throws Exception {
cellRow = 2;
str = ExcelUtility.getCellData(cellRow, 0);
while(str != "End of Data"){
login.setUsernameTB(ExcelUtility.getCellData(cellRow, 1));
login.setPasswordTB(ExcelUtility.getCellData(cellRow, 2));
login.clickLoginBT();
str = ExcelUtility.getCellData(cellRow, 4);
if(str.equals("Y")){
Assert.assertTrue("Login Unsuccessful", login.assertSuccessfulLogin());
dashboard.clickLogoutBT();
}else{
by = By.xpath(ExcelUtility.getCellData(cellRow, 5));
login.waitForElementToBeVisible(by);
Assert.assertTrue("Login Successful", login.getElement(by).isDisplayed());
login.clearLoginBoxes();
}
cellRow++;
str = ExcelUtility.getCellData(cellRow, 0);
}
}
Thanks in advance (and sorry for the shabby coding).