Reputation: 39
I want to add test data used in test case execution in Extent Report selenium. e.g. I have used username soni691 & password: 691990 in a login method. Then if this test case is passed I want to display in the extent report that this username & pwd is used to login into the page.
I want to know if this is possible?
Upvotes: 1
Views: 2213
Reputation: 143
On the ExtentTest instance you can call the info method which accepts any String. Apart from info you can call pass, fail, error and a few more. Use these to log the steps and assertions you take.
You could try something like the below.
ExtentReports extentReports = new ExtentReports();
ExtentTest test = extentReports.createTest("SomeName");
ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter("Test.html");//Constructor takes a path
extentReports.attachReporter(htmlReporter);
String user = "MyUser";
String pass = "MyPass";
test.info(String.format("username: %s; password: %s", user, pass));
reports.flush();
pom.xml dependency:
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.1</version>
EDIT: Since I cant comment yet Ill just edit the answer.
The source of data wont matter as long as you can make a String out of it. Since you can send the username and password I suppose you already have them in some variable.
EDIT2: I wrote the wrong variable name here. Didnt mean extent but rather extentReports which I initilized the row before.
EDIT3: Added flush to finish up the flow of creating a whole report.
EDIT4: Added Maven dependancy to be clear about the version and version number of the extent report used
EDIT5: Added Reporter
Upvotes: 1