Skip to content

Commit 4cdb353

Browse files
committed
Changed what exception is thrown when no element is found in the shadow dom
1 parent 6453052 commit 4cdb353

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

bellatrix.web/src/main/java/solutions/bellatrix/web/components/shadowdom/ShadowDomService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import lombok.experimental.UtilityClass;
1717
import org.openqa.selenium.By;
18+
import org.openqa.selenium.NoSuchElementException;
1819
import solutions.bellatrix.core.configuration.ConfigurationService;
1920
import solutions.bellatrix.core.utilities.InstanceFactory;
2021
import solutions.bellatrix.core.utilities.Ref;
@@ -261,7 +262,7 @@ private static <TComponent extends WebComponent> TComponent retryFindingSingleCo
261262
throw new RuntimeException(e);
262263
}
263264
} else {
264-
throw new IllegalArgumentException("No element inside the shadow DOM was found with the findStrategy: " + findStrategy.toString());
265+
throw new NoSuchElementException("No element inside the shadow DOM was found with the findStrategy: " + findStrategy.toString());
265266
}
266267
}
267268

framework-tests/bellatrix.web.tests/src/test/java/controls/shadowdom/ShadowDomTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.junit.jupiter.api.Assertions;
55
import org.junit.jupiter.api.BeforeEach;
66
import org.junit.jupiter.api.Test;
7+
import org.openqa.selenium.NoSuchElementException;
78
import solutions.bellatrix.core.configuration.ConfigurationService;
89
import solutions.bellatrix.web.components.Anchor;
910
import solutions.bellatrix.web.components.Div;
@@ -112,7 +113,7 @@ public void exceptionThrown_when_tryingToFindNonExistentElement() {
112113
var shadowHost = app().create().byId(Div.class, "complexShadowHost");
113114
var shadowRoot = shadowHost.getShadowRoot();
114115

115-
Assertions.assertThrows(IllegalArgumentException.class, () -> shadowRoot.createByXPath(Div.class, "//nonExistentElement"));
116+
Assertions.assertThrows(NoSuchElementException.class, () -> shadowRoot.createByXPath(Div.class, "//nonExistentElement"));
116117
}
117118

118119
@Test

0 commit comments

Comments
 (0)