Skip to content
This repository was archived by the owner on Dec 13, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions src/main/java/com/crossbrowsertesting/AutomatedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@



import com.mashape.unirest.request.GetRequest;
import org.apache.commons.codec.binary.Base64;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
Expand Down Expand Up @@ -94,9 +95,7 @@ public Snapshot takeSnapshot(String description) throws UnirestException {//over

public Snapshot[] getSnapshots() throws UnirestException {
Snapshot[] snaps;
HttpResponse<String> response = Unirest.get(Builders.api + this.testId + "/snapshots")
.basicAuth(Builders.username, Builders.authkey)
.asString();
HttpResponse<String> response = doGet("/snapshots").asString();
JSONArray results = new JSONArray(response.getBody());
String hash;
snaps = new Snapshot[results.length()];
Expand All @@ -118,9 +117,7 @@ public Video startRecordingVideo() throws UnirestException {

public Video[] getVideos() throws UnirestException {
Video[] videos;
HttpResponse<String> response = Unirest.get(Builders.api + this.testId + "/videos")
.basicAuth(Builders.username, Builders.authkey)
.asString();
HttpResponse<String> response = doGet("/videos").asString();
JSONArray results = new JSONArray(response.getBody());
String hash;
videos = new Video[results.length()];
Expand Down Expand Up @@ -169,4 +166,16 @@ public void saveAllVideos(String directory, boolean useDescription) throws Unire
count++;
}
}
}

public String getWebUrl() throws UnirestException {
return doGet("").asJson()
.getBody()
.getObject()
.getString("show_result_web_url");
}

private GetRequest doGet(String relativeUrl) {
return Unirest.get(Builders.api + this.testId + relativeUrl)
.basicAuth(Builders.username, Builders.authkey);
}
}