Search in sources :

Example 6 with TestInformation

use of de.zalando.ep.zalenium.dashboard.TestInformation in project zalenium by zalando.

the class SauceLabsRemoteProxy method getTestInformation.

@Override
public TestInformation getTestInformation(String seleniumSessionId) {
    // https://saucelabs.com/rest/v1/SL_USER/jobs/SELENIUM_SESSION_ID
    String sauceLabsTestUrl = "https://saucelabs.com/rest/v1/%s/jobs/%s";
    sauceLabsTestUrl = String.format(sauceLabsTestUrl, SAUCE_LABS_USER_NAME, seleniumSessionId);
    String sauceLabsVideoUrl = sauceLabsTestUrl + "/assets/video.flv";
    String sauceLabsBrowserLogUrl = sauceLabsTestUrl + "/assets/log.json";
    String sauceLabsSeleniumLogUrl = sauceLabsTestUrl + "/assets/selenium-server.log";
    JsonObject testData = getCommonProxyUtilities().readJSONFromUrl(sauceLabsTestUrl, SAUCE_LABS_USER_NAME, SAUCE_LABS_ACCESS_KEY).getAsJsonObject();
    String testName = testData.get("name").isJsonNull() ? null : testData.get("name").getAsString();
    String browser = testData.get("browser").isJsonNull() ? "N/A" : testData.get("browser").getAsString();
    String browserVersion = testData.get("browser_short_version").isJsonNull() ? "N/A" : testData.get("browser_short_version").getAsString();
    String platform = testData.get("os").getAsString();
    List<String> logUrls = new ArrayList<>();
    logUrls.add(sauceLabsBrowserLogUrl);
    logUrls.add(sauceLabsSeleniumLogUrl);
    return new TestInformation.TestInformationBuilder().withSeleniumSessionId(seleniumSessionId).withTestName(testName).withProxyName(getProxyName()).withBrowser(browser).withBrowserVersion(browserVersion).withPlatform(platform).withTestStatus(TestInformation.TestStatus.COMPLETED).withFileExtension(getVideoFileExtension()).withVideoUrl(sauceLabsVideoUrl).withLogUrls(logUrls).build();
}
Also used : TestInformation(de.zalando.ep.zalenium.dashboard.TestInformation) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject)

Aggregations

TestInformation (de.zalando.ep.zalenium.dashboard.TestInformation)6 JsonObject (com.google.gson.JsonObject)5 HashMap (java.util.HashMap)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 Test (org.junit.Test)4 ExternalSessionKey (org.openqa.grid.internal.ExternalSessionKey)4 TestSession (org.openqa.grid.internal.TestSession)4 WebDriverRequest (org.openqa.grid.web.servlet.handler.WebDriverRequest)4 CommonProxyUtilities (de.zalando.ep.zalenium.util.CommonProxyUtilities)3 JsonElement (com.google.gson.JsonElement)2 ArrayList (java.util.ArrayList)2 Environment (de.zalando.ep.zalenium.util.Environment)1 File (java.io.File)1 Mockito.anyString (org.mockito.Mockito.anyString)1