/
Utils.java
49 lines (42 loc) · 1.92 KB
/
Utils.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package com.perfecto.testng;
import java.util.HashMap;
import java.util.Map;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebDriver;
import com.perfecto.reportium.client.ReportiumClient;
import com.perfecto.reportium.client.ReportiumClientFactory;
import com.perfecto.reportium.model.Job;
import com.perfecto.reportium.model.PerfectoExecutionContext;
import com.perfecto.reportium.model.Project;
public class Utils {
/**
* Creates reportium client
* @param driver
* @param reportiumClient
* @return
* @throws Exception
*/
public static ReportiumClient setReportiumClient(RemoteWebDriver driver, ReportiumClient reportiumClient, String tag) throws Exception {
PerfectoExecutionContext perfectoExecutionContext;
// Reporting client. For more details, see https://developers.perfectomobile.com/display/PD/Java
if(System.getProperty("reportium-job-name") != null) {
perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
.withProject(new Project("My Project", "1.0"))
.withJob(new Job(System.getProperty("reportium-job-name") , Integer.parseInt(System.getProperty("reportium-job-number"))))
.withContextTags(tag)
.withWebDriver(driver)
.build();
} else {
perfectoExecutionContext = new PerfectoExecutionContext.PerfectoExecutionContextBuilder()
.withProject(new Project("My Project", "1.0"))
.withContextTags(tag)
.withWebDriver(driver)
.build();
}
reportiumClient = new ReportiumClientFactory().createPerfectoReportiumClient(perfectoExecutionContext);
if (reportiumClient == null) {
throw new Exception("Reportium client not created!");
}
return reportiumClient;
}
}