TestProject Forum
Powered by leading experts in the test automation community

How do I get my reporter in coded tests to display a message in my generated report

Java SDK suggests the use of Reporter Class.
But I see no message after the test execution is complete

Hello Sai :slight_smile:

To get reports for your step first you need to declare
TestReporter testReporter = helper.getReporter()
in your executetable class.

And after this, where you want to get a step report you can use this :
testReporter.step();

Here’s the example :
TestReporter reporter = helper.getReporter();
boolean result;
By by;
by = By.xpath("//input[@value='Login']");
result = driver.testproject().clickIfVisible(by);
reporter.step("Click Login Button","Failed to click login button","Login button clicked",result, TakeScreenshotConditionType.Failure);

Ok
What does the reporter.result(String expression) do?
If I want to just send a message after a sussecful step how do I send it?
Should I just leave the Failed Message Empty?
Or any method for that?

It’s a message that you want to see in step report. You can combine it with values, for example like this :

String currentLink = driver.testproject().getCurrentUrl();

reporter.step("Current URL is ["+currentLink+"]");

You can use just the the description for steps, and of course you can leave failure message just " "

Yes, I am aware of that.
But that reporter.step() with only String argument is not displaying any message when the step is successful.
image
image

Can you please try, just to see if it works, use the report out of conditional expression?

Btw side note I am getting this everytime I upload a new version of the coded Test
It works If I delete the step in all the tests But obviously that is not the right way.
Can you tell me what I am doing wrong
image

Same Thing and it has an else so I dont think thats the issue
image

Can you also try to use this?
With adding a boolean to check if action was successful.
Example:
boolean result;
result = driver.findElement(By.xpath(xpath)).click();
reporter.step("Click action","Failed","Successful", result, TakeScreenshotConditionType.Failure);

return type is void
But sure Ill just give true and test it
Edit: Please note that when the test fails It does work

image
Same No message.
image

Hi @SaiPreetham,

What is your agent version? Also, can you please download the latest Java SDK version?

Latest SDK and Agent vversion

Showing up in step message but not in Generated report

Actually I just checked it myself and it is working as expected.Are you sure that you uploaded the new version of your test to TestProject?

image

Well, I guess it is working now, right?

Yes
I am curious is there a way to write something in the generated report?

You can write whatever you want in the success/failure message. In your case, you wrote “Successful”, but you could also write something else.

Yes That is for the message in the report. I understand that.
I would like to know if there is a method in the provided SDK which lets me display messages in the downloaded PDF report.