Skip to content

Commit 39c8f27

Browse files
committed
revert to last commit
1 parent 52ebf42 commit 39c8f27

File tree

3 files changed

+5
-75
lines changed

3 files changed

+5
-75
lines changed

.vscode/settings.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/main/java/MyRunner/TestRunner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ public void setUpClass(String browser, String version, String platform) throws E
4040
capability.setCapability(CapabilityType.VERSION, version);
4141
capability.setCapability(CapabilityType.PLATFORM, platform);
4242

43-
capability.setCapability("build", "Cucumber Autuer Build");
43+
capability.setCapability("build", "Cucumber Sample Build");
4444

45-
capability.setCapability("network", true);
46-
capability.setCapability("video", true);
47-
capability.setCapability("console", true);
48-
capability.setCapability("visual", true);
45+
// capability.setCapability("network", true);
46+
// capability.setCapability("video", true);
47+
// capability.setCapability("console", true);
48+
// capability.setCapability("visual", true);
4949

5050
String gridURL = "https://" + username + ":" + accesskey + "@hub.lambdatest.com/wd/hub";
5151
System.out.println(gridURL);
Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
package stepDefinitions;
22

33
import io.cucumber.java.After;
4-
import io.cucumber.java.AfterStep;
54
import io.cucumber.java.Before;
65
import io.cucumber.java.Scenario;
76
import manager.Driver;
87
import manager.DriverManager;
98
import org.openqa.selenium.remote.RemoteWebDriver;
10-
import java.io.IOException;
11-
import java.io.InputStream;
12-
import java.net.HttpURLConnection;
13-
import java.net.URL;
14-
import java.nio.file.Files;
15-
import java.nio.file.Path;
16-
import java.nio.file.Paths;
17-
import java.nio.file.StandardCopyOption;
18-
import org.json.JSONObject;
19-
import java.io.OutputStream;
20-
import java.util.Base64;
219

2210
public class Hook {
2311
public RemoteWebDriver driver = DriverManager.getDriver();
@@ -27,66 +15,12 @@ public void updateName(Scenario scenario) throws InterruptedException {
2715
driver.executeScript("lambda-name=" + scenario.getName());
2816
}
2917

30-
@AfterStep
31-
public void captureDom() throws InterruptedException {
32-
driver.executeScript("return document.documentElement.outerHTML;");
33-
}
34-
3518
@After
3619
public void close_the_browser(Scenario scenario) throws InterruptedException {
3720
driver.executeScript("lambda-status=" + (scenario.isFailed() ? "failed" : "passed"));
38-
3921
String testId = driver.getSessionId().toString();
4022
System.out.println(testId);
41-
Thread.sleep(20000);
42-
downloadFiles(testId,System.getenv("LT_USERNAME"),System.getenv("LT_ACCESS_KEY"));
4323
Driver.quitDriver();
4424
}
4525

46-
public static void downloadFiles(String testId, String username, String accessKey) {
47-
String directoryPath = "./" + testId;
48-
String apiUrl = "https://api.lambdatest.com/automation/api/v1/sessions/" + testId + "/results";
49-
50-
// Encode username and access key
51-
String authValue = Base64.getEncoder().encodeToString((username + ":" + accessKey).getBytes());
52-
53-
try {
54-
// Create directory for testId if it doesn't already exist
55-
Path directory = Paths.get(directoryPath);
56-
if (!Files.exists(directory)) {
57-
Files.createDirectories(directory);
58-
}
59-
60-
// Download ZIP file containing results
61-
downloadFile(apiUrl, authValue, Paths.get(directoryPath, testId + "_results.zip"));
62-
63-
System.out.println("ZIP file downloaded successfully.");
64-
} catch (IOException e) {
65-
System.err.println("Error downloading the ZIP file: " + e.getMessage());
66-
}
67-
}
68-
69-
private static void downloadFile(String fileUrl, String authValue, Path targetPath) throws IOException {
70-
URL url = new URL(fileUrl);
71-
HttpURLConnection httpConn = (HttpURLConnection) url.openConnection();
72-
httpConn.setRequestMethod("GET");
73-
httpConn.setRequestProperty("Authorization", "Basic " + authValue);
74-
75-
// Check response code and handle input stream accordingly
76-
if (httpConn.getResponseCode() == HttpURLConnection.HTTP_OK) {
77-
try (InputStream in = httpConn.getInputStream();
78-
OutputStream out = Files.newOutputStream(targetPath)) {
79-
byte[] buffer = new byte[4096];
80-
int bytesRead;
81-
while ((bytesRead = in.read(buffer)) != -1) {
82-
out.write(buffer, 0, bytesRead);
83-
}
84-
}
85-
} else {
86-
throw new IOException("Server returned non-OK status: " + httpConn.getResponseCode());
87-
}
88-
89-
httpConn.disconnect();
90-
}
91-
9226
}

0 commit comments

Comments
 (0)