Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dot-4397] add sessionId in java selenium wrapper #13

Open
wants to merge 2 commits into
base: stage
Choose a base branch
from
Open
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/main/java/io/github/lambdatest/SmartUISnapshot.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public static void smartuiSnapshot(WebDriver driver, String snapshotName, Map<St
// Execute script with the fetched DOM string
((JavascriptExecutor) driver).executeScript(domString);

// Append sessionId to options
String sessionId = ((org.openqa.selenium.remote.RemoteWebDriver) driver).getSessionId().toString();
if (!sessionId.isEmpty()) {
options.put("sessionId", sessionId);
}

// Convert the options map to JSON string
String jsonOptions = gson.toJson(options);

Expand All @@ -76,7 +82,7 @@ public static void smartuiSnapshot(WebDriver driver, String snapshotName, Map<St
}

String url = driver.getCurrentUrl();

String ResponseMap = smartUIUtils.postSnapshot(dom, options, url, snapshotName, "lambdatest-java-sdk");

// Parse the JSON response into a SnapshotResponse object using Gson
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/github/lambdatest/utils/SmartUIUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public static String getSmartUIServerAddress() {
if (smartUiServerAddress != null && !smartUiServerAddress.isEmpty()) {
return smartUiServerAddress;
} else {
throw new RuntimeException("SmartUI server address not found");
return "http://localhost:49152";
}
}


}