Skip to content

Commit

Permalink
Navigation fix (#1254)
Browse files Browse the repository at this point in the history
* Handle navigation exception

* Handle FailureReporter NullPointerException

* Release 7.3.20230825

* Release 7.3.20230825.1

* Release 7.3.20230824.1
  • Loading branch information
MahmoudElSharkawy authored Aug 24, 2023
1 parent fe003bf commit 7bb7d1c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.shafthq</groupId>
<artifactId>SHAFT_ENGINE</artifactId>
<version>7.3.20230824</version> <!-- UPDATE com.shaft.properties.internal > Internal -->
<version>7.3.20230824.1</version> <!-- UPDATE com.shaft.properties.internal > Internal -->
<name>${project.groupId}:${project.artifactId}</name>
<description>SHAFT is a unified test automation engine. Powered by best-in-class frameworks, SHAFT provides a
wizard-like syntax to drive your automation efficiently, maximize your ROI, and minimize your learning curve.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ public static void navigateToNewUrl(WebDriver driver, String initialURL, String
try {
// upgrading to w3c compliant browsing context for navigation
new BrowsingContext(driver, driver.getWindowHandle()).navigate(internalURL, ReadinessState.COMPLETE);
} catch (java.lang.IllegalArgumentException | org.openqa.selenium.bidi.BiDiException illegalArgumentException) {
} catch (TimeoutException | java.lang.IllegalArgumentException | org.openqa.selenium.bidi.BiDiException illegalArgumentException) {
// Caused by: java.lang.IllegalArgumentException: WebDriver instance must support BiDi protocol
// Caused by: org.openqa.selenium.bidi.BiDiException: Unable to create a BiDi connection
// TimeoutException: Happens sometimes with some proxy environments
driver.navigate().to(internalURL);
} catch (WebDriverException rootCauseException) {
failAction(driver, targetUrl, rootCauseException);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/shaft/properties/internal/Internal.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
})
public interface Internal extends EngineProperties {
@Key("shaftEngineVersion")
@DefaultValue("7.3.20230824")
@DefaultValue("7.3.20230824.1")
String shaftEngineVersion();

@Key("watermarkImagePath")
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/shaft/tools/io/internal/FailureReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
public class FailureReporter {
public static void fail(Class<?> failedFileManager, String message, Throwable throwable) {
String actionName = "fail";
String localizedMessage = "";
if (!Throwables.getRootCause(throwable).getLocalizedMessage().equals(null)) {
localizedMessage = Throwables.getRootCause(throwable).getLocalizedMessage();
String rootCause;
try {
rootCause = " Root cause: \"" + Throwables.getRootCause(throwable).getClass().getName() + ": " + Throwables.getRootCause(throwable).getLocalizedMessage().split("\n")[0] + "\"";
} catch (NullPointerException e) {
rootCause = " Root cause: \"" + Throwables.getRootCause(throwable).getClass().getName() + ": ".split("\n")[0] + "\"";
}
String rootCause = " Root cause: \"" + Throwables.getRootCause(throwable).getClass().getName() + ": " + localizedMessage.split("\n")[0] + "\"";

for (StackTraceElement stackTraceElement : Arrays.stream(Thread.currentThread().getStackTrace()).toList()) {
var methodName = stackTraceElement.getMethodName();
if (!methodName.toLowerCase().contains("fail")) {
Expand Down

0 comments on commit 7bb7d1c

Please sign in to comment.