Closed Stefankoff closed 1 year ago
Maybe you have some knowledge in Java how to that? I wrote some methods public static void setTestInfo(String sessionId, String testName, String testStatus, String error) throws IOException, InterruptedException {
` String url = "http://localhost:4723/session/" + sessionId + "/setTestInfo";
var jsonBody = new HashMap<String,String>();
jsonBody.put("testName", testName);
jsonBody.put("testStatus", testStatus);
jsonBody.put("error", error);
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create(url))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(String.valueOf(jsonBody)))
.build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
}
public static String getReport() throws IOException, InterruptedException {
String url = "http://localhost:4723/getReport";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create(url)).build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
return String.valueOf(response);
}
public static void deleteReportData() throws IOException, InterruptedException {
String url = "http://localhost:4723/deleteReportData";
var client = HttpClient.newHttpClient();
var request = HttpRequest.newBuilder(URI.create(url)).DELETE().build();
var response = client.send(request, HttpResponse.BodyHandlers.ofString());
}
public static void createReportFile(String data, String fileName) throws IOException {
FileWriter fileWriter = new FileWriter(HTML_REPORT_DIR + "/" + fileName + ".html");
fileWriter.write(data);
fileWriter.close();
}`
Could you please say what maybe wrong, and how to use this methods in test flow as in your example https://github.com/AppiumTestDistribution/appium-reporter-plugin/blob/main/test/demo/demo.spec.js
@Stefankoff identified a couple of improvements while coding a sample in java. Fixed them and released a new version.
Java project is added to tests folder appium-reporter-plugin/test/AppiumReportPluginDemo/src/test/java/SampleTest.java
I hope this helps!
Sure you can.
For now hoping below steps would help
appium plugin install --source=npm appium-reporter-plugin
appium --use-plugins=appium-reporter-plugin