I am running Selenium tests using Java (TestNG and IntelliJ) and am currently working on my reporting framework. My test setup looks something like this:
@Test
public void testLogin(){
myKeyword.login();
}
myKeyword is the keyword class I created using the login method. The login keyword will look like this:
public void login(){
myPage.typeInTextBox("Username");
myPage.typeInTextBox("Password");
myPage.buttonClick("Login");
}
My check is built into the "buttonClick" and "typeInTextBox" methods. They will look something like this:
try{
driver.findelement(By.id("myButton")).click();
}
catch (Exception e){
Assert.fail("Could not click on the button.");
}
What I want to know is it possible for the "buttonClick" method to know the name of the test calling it?
"Assert.fail..." , , , , ( "testLogin".