Skip to content

Commit 7f436e0

Browse files
authored
Merge pull request #13 from parthlambdatest/Dot-4397
[Dot-4397] add sessionId in java selenium wrapper
2 parents 4cafce4 + 347e260 commit 7f436e0

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

build.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
}
77

88
group = 'io.github.lambdatest'
9-
version = '1.0.4'
9+
version = '1.0.6'
1010
description = 'lambdatest-java-sdk'
1111

1212
repositories {
@@ -17,7 +17,7 @@ repositories {
1717
dependencies {
1818
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
1919
implementation 'org.json:json:20231013'
20-
implementation 'org.seleniumhq.selenium:selenium-java:4.14.0'
20+
compileOnly 'org.seleniumhq.selenium:selenium-java:[4.0.0,)'
2121
implementation 'com.google.code.gson:gson:2.10.1'
2222
implementation 'io.netty:netty-transport-native-epoll:4.1.104.Final'
2323
implementation 'io.netty:netty-transport-native-kqueue:4.1.104.Final'
@@ -77,7 +77,7 @@ afterEvaluate {
7777
mavenJava(MavenPublication) {
7878
groupId = 'io.github.lambdatest'
7979
artifactId = 'lambdatest-java-sdk'
80-
version = '1.0.4'
80+
version = '1.0.6'
8181

8282
pom {
8383
name.set('LambdaTest Java SDK')

src/main/java/io/github/lambdatest/SmartUISnapshot.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ public static void smartuiSnapshot(WebDriver driver, String snapshotName, Map<St
5959
// Execute script with the fetched DOM string
6060
((JavascriptExecutor) driver).executeScript(domString);
6161

62+
// Append sessionId to options
63+
String sessionId = ((org.openqa.selenium.remote.RemoteWebDriver) driver).getSessionId().toString();
64+
if (!sessionId.isEmpty()) {
65+
options.put("sessionId", sessionId);
66+
}
67+
6268
// Convert the options map to JSON string
6369
String jsonOptions = gson.toJson(options);
6470

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

7884
String url = driver.getCurrentUrl();
79-
85+
8086
String ResponseMap = smartUIUtils.postSnapshot(dom, options, url, snapshotName, "lambdatest-java-sdk");
8187

8288
// Parse the JSON response into a SnapshotResponse object using Gson

src/main/java/io/github/lambdatest/utils/SmartUIUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public static String getSmartUIServerAddress() {
6666
if (smartUiServerAddress != null && !smartUiServerAddress.isEmpty()) {
6767
return smartUiServerAddress;
6868
} else {
69-
throw new RuntimeException("SmartUI server address not found");
69+
return "http://localhost:49152";
7070
}
7171
}
7272

73+
7374
}

0 commit comments

Comments
 (0)