Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRemoteWebDriverTest.java
More file actions
Latest commit
129 lines (110 loc) · 5.59 KB
/
Copy pathRemoteWebDriverTest.java
File metadata and controls
129 lines (110 loc) · 5.59 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
importcom.perfecto.reportium.client.ReportiumClient;
importcom.perfecto.reportium.client.ReportiumClientFactory;
importcom.perfecto.reportium.model.Job;
importcom.perfecto.reportium.model.PerfectoExecutionContext;
importcom.perfecto.reportium.model.Project;
importcom.perfecto.reportium.test.TestContext;
importcom.perfecto.reportium.test.result.TestResultFactory;
importorg.openqa.selenium.By;
importorg.openqa.selenium.remote.*;
importorg.testng.ITestResult;
importorg.testng.annotations.*;
importjavax.rmi.CORBA.Util;
importjava.net.MalformedURLException;
/**
* For programming samples and updated templates refer to the Perfecto GitHub at: https://github.com/PerfectoCode
*/
publicclassRemoteWebDriverTest {
privateRemoteWebDriverdriver;
privateReportiumClientreportiumClient;
privatestaticfinalStringTestNamePrefix = "Perfecto DigitalZoom Reporting - ";
privateStringTestName;
/**
* BeforeMethod
* run before each test method
* setup a RemoteWebDriver instance and ReportiumClient
* @param platformName - capability
* @param platformVersion - capability
* @param browserName - capability
* @param browserVersion - capability
* @param screenResolution - capability
* @param model - capability
* @throws MalformedURLException
*/
@Parameters({"platformName", "platformVersion", "browserName", "browserVersion", "screenResolution", "model"})
@BeforeMethod
publicvoidBeforeMethod(StringplatformName, StringplatformVersion, StringbrowserName
, StringbrowserVersion, StringscreenResolution, Stringmodel) throwsMalformedURLException {
// Standard RemoteWebDriver
driver = Utils.getRemoteWebDriver(platformName, platformVersion, browserName, browserVersion, screenResolution, model);
// Setup ReportuimClient instance see Utils class for more information
reportiumClient = Utils.createReportiumClient(driver , "Tag1", "Tag2", "Tag3");
// test name to be passes later to the testStart command
TestName = TestNamePrefix + platformName;
}
/**
* Test method
* the test to be run right after BeforeMethod
* @param platformName - passed from TestNG
* @param platformVersion - passed from TestNG
* @param browserName - passed from TestNG
*/
@Parameters({"platformName", "platformVersion", "browserName"})
@Test
publicvoidTest(StringplatformName, StringplatformVersion, StringbrowserName) {
reportiumClient.testStart(TestName, newTestContext(platformName, platformVersion, browserName));
reportiumClient.testStep("Open google"); // testStep
driver.get("https://www.google.com/");
reportiumClient.testStep("Search PerfectoCode"); // testStep
driver.findElement(By.name("q")).sendKeys("PerfectoCode");
/**
* Complete your test here ...
*/
}
/**
* AfterMethod
* run after test
* pass to reportiumClient the test result using testStop command
* printing the report URL and download report PDF link.
* @param result - test result passed automatically from TestNG
*/
@AfterMethod
publicvoidAfterMethod(ITestResultresult) {
// Finish the test and determine the results
if (result.isSuccess()) {
// On successful test
reportiumClient.testStop(TestResultFactory.createSuccess());
} else {
Throwablet = result.getThrowable(); // Case of failure, rescue the exception message
reportiumClient.testStop(TestResultFactory.createFailure(t.getMessage(), t));
}
try {
driver.quit();
// Retrieve the URL to the DigitalZoom Report (= Reportium Application) for an aggregated view over the execution
StringreportURL = reportiumClient.getReportUrl();
System.out.println("************ Report URL ************");
System.out.println(reportURL);
System.out.println("************************************");
// Retrieve the URL to the Execution Summary PDF Report
StringreportPdfUrl = (String) (driver.getCapabilities().getCapability("reportPdfUrl"));
System.out.println("************ Report PDF Download ************");
System.out.println(reportPdfUrl);
System.out.println("*********************************************");
// For detailed documentation on how to export the Execution Summary PDF Report, the Single Test report and other attachments such as
// video, images, device logs, vitals and network files - see http://developers.perfectomobile.com/display/PD/Exporting+the+Reports
} catch (Exceptione) {
e.printStackTrace();
}
}
@AfterClass
publicvoidafterClass(){
Stringhost = System.getenv("PERFECTO_HOST"); // Your PerfectoLab host
Stringserv = System.getenv("REPORTING_SERVER"); // Reporting server
Stringjobn = System.getenv("CIRCLE_PROJECT_REPONAME"); // Job name
Stringjobv = System.getenv("CIRCLE_BUILD_NUM"); // Job number
System.out.println("=================================================================");
System.out.println("See the complete report at: ");
System.out.println("https://" + host + "." + serv + ".perfectomobile.com/?jobName[0]=" + jobn + "&jobNumber[0]=" + jobv);
System.out.println("=================================================================");
}
}