diff --git a/README.md b/README.md
index ceaf9ce..8ec8c6e 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,7 @@ Self-healing library for Selenium Web-based tests
for Gradle projects:
```
dependencies {
- compile group: 'com.epam.healenium', name: 'healenium-web', version: '3.5.7'
+ compile group: 'com.epam.healenium', name: 'healenium-web', version: '3.5.8'
}
```
@@ -22,7 +22,7 @@ for Maven projects:
com.epam.healenium
healenium-web
- 3.5.7
+ 3.5.8
```
### 1. Init driver instance of SelfHealingDriver
diff --git a/pom.xml b/pom.xml
index 358137c..e281af3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
4.0.0
com.epam.healenium
healenium-web
- 3.5.7
+ 3.5.8
jar
healenium-web
healenium web client
@@ -55,13 +55,13 @@
1.15
23.0.0
1.4.2.Final
- 1.18.22
+ 1.18.38
0.8.1
12.0.17
2.2
7.0.0
- 1.19.8
- 5.8.2
+ 1.21.4
+ 5.11.3
6.1.0
17
17
@@ -240,7 +240,7 @@
org.slf4j
slf4j-simple
- 2.0.9
+ 2.0.17
one.util
diff --git a/src/main/java/com/epam/healenium/client/RestClient.java b/src/main/java/com/epam/healenium/client/RestClient.java
index c63c8c4..00455eb 100644
--- a/src/main/java/com/epam/healenium/client/RestClient.java
+++ b/src/main/java/com/epam/healenium/client/RestClient.java
@@ -50,6 +50,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -68,20 +69,27 @@ public class RestClient {
private final String serverUrl;
private final String imitateUrl;
+ private final String aiServiceUrl;
private final String sessionKey;
+ private final String selectorType;
private ObjectMapper objectMapper;
private HealeniumMapper mapper;
private HttpClient serverHttpClient;
private HttpClient imitateHttpClient;
+ private HttpClient aiServiceHttpClient;
public RestClient(Config config) {
this.objectMapper = initMapper();
this.sessionKey = config.getString("sessionKey");
this.serverUrl = getHttpUrl(config.getString("hlm.server.url"), "/healenium");
this.imitateUrl = getHttpUrl(config.getString("hlm.imitator.url"), "/imitate");
+ this.aiServiceUrl = getHttpUrl(config.getString("hlm.ai.url"), "/healenium-ai");
+ this.selectorType = config.hasPath("selector-type") ? config.getString("selector-type") : "cssSelector";
this.serverHttpClient = getHttpClient(serverUrl);
this.imitateHttpClient = getHttpClient(imitateUrl);
- log.debug("[Init] sessionKey: {}, serverUrl: {}, imitateUrl: {}", sessionKey, serverUrl, imitateUrl);
+ this.aiServiceHttpClient = getHttpClient(aiServiceUrl);
+ log.debug("[Init] sessionKey: {}, serverUrl: {}, imitateUrl: {}, selectorType: {}",
+ sessionKey, serverUrl, imitateUrl, selectorType);
}
private String getHttpUrl(String hlmServerUrl, String path) {
@@ -261,6 +269,42 @@ public void initReport(String sessionId) {
}
}
+ public String getXpathSelector(Node node, String sessionId) {
+ String xpath = null;
+ try {
+ if (node == null) {
+ log.error("[Get Xpath Selector] Node is null, cannot proceed with request");
+ return null;
+ }
+
+ log.debug("[Get Xpath Selector] Node details - Tag: {}, ID: {}, Classes: {}",
+ node.getTag(), node.getId(), node.getClasses());
+
+ HttpRequest request = new HttpRequest(HttpMethod.POST, "/selectors/xpath");
+ String content = objectMapper.writeValueAsString(node);
+ log.debug("[Get Xpath Selector] Request body: {}", content);
+ byte[] data = content.getBytes(StandardCharsets.UTF_8);
+ request.setHeader("Content-Length", String.valueOf(data.length));
+ request.setHeader("Content-Type", JSON_UTF_8);
+ request.setHeader("X-Session-Id", sessionId);
+ request.setContent(Contents.bytes(data));
+ HttpResponse response = aiServiceExecute(request);
+
+ if (HTTP_NOT_FOUND == response.getStatus()) {
+ throw new RuntimeException("[Get Xpath Selector] Compatibility error. You must have a paid hlm-ai service.");
+ }
+ Supplier result = response.getContent();
+ Map responseMap = objectMapper.readValue(result.get(), new TypeReference