I have a BDD file having certain steps, like below:
Given user navigates to login page.
When user enters username.
And user enters password.
Then user clicks on login button.
The step definition file is something like below:
@CustomAnnotation(description="When user enters {}")
public void enterTextInAnyField(WebElement element,String txt)
{
ele.sendKeys(txt);
}
My requirement is to get the currently executing BDD line in String format from inside the step definition method (enterTextInAnyField). The step definition would only get executed when the step matches, so in this case my expected output would be:
String txt="When user enters username"
OR
String txt="And user enters password"
Can someone please help me with this. Thanks.