|
5 | 5 | import org.junit.jupiter.api.BeforeEach; |
6 | 6 | import org.junit.jupiter.api.Test; |
7 | 7 | import org.openqa.selenium.NoSuchElementException; |
| 8 | +import org.testng.asserts.Assertion; |
8 | 9 | import solutions.bellatrix.core.configuration.ConfigurationService; |
9 | 10 | import solutions.bellatrix.web.components.Anchor; |
10 | 11 | import solutions.bellatrix.web.components.Div; |
11 | 12 | import solutions.bellatrix.web.components.Select; |
12 | 13 | import solutions.bellatrix.web.components.advanced.grid.Grid; |
13 | 14 | import solutions.bellatrix.web.components.advanced.grid.GridCell; |
14 | 15 | import solutions.bellatrix.web.components.shadowdom.ShadowRoot; |
| 16 | +import solutions.bellatrix.web.configuration.WebSettings; |
15 | 17 | import solutions.bellatrix.web.infrastructure.Browser; |
16 | 18 | import solutions.bellatrix.web.infrastructure.ExecutionBrowser; |
17 | 19 | import solutions.bellatrix.web.infrastructure.Lifecycle; |
@@ -127,5 +129,37 @@ public void returnedEmptyList_when_tryingToFindNonExistentElements() { |
127 | 129 | ); |
128 | 130 | } |
129 | 131 |
|
| 132 | + @Test |
| 133 | + public void waitedTimeout_when_tryingToFindNonExistentElement() { |
| 134 | + var shadowHost = app().create().byId(Div.class, "complexShadowHost"); |
| 135 | + var shadowRoot = shadowHost.getShadowRoot(); |
| 136 | + |
| 137 | + long startTime = System.currentTimeMillis(); |
| 138 | + try { |
| 139 | + shadowRoot.createByXPath(Div.class, "//nonExistentElement"); |
| 140 | + } catch (NoSuchElementException ignored) { |
| 141 | + var elapsedTime = System.currentTimeMillis() - startTime; |
| 142 | + |
| 143 | + Assertions.assertTrue(elapsedTime > ConfigurationService.get(WebSettings.class).getTimeoutSettings().getElementWaitTimeout()*1000); |
| 144 | + } |
| 145 | + } |
| 146 | + |
| 147 | + @Test |
| 148 | + public void returnedEmptyListWithoutWaiting_when_tryingToFindNonExistentElements() { |
| 149 | + var shadowHost = app().create().byId(Div.class, "complexShadowHost"); |
| 150 | + var shadowRoot = shadowHost.getShadowRoot(); |
| 151 | + |
| 152 | + long startTime = System.currentTimeMillis(); |
| 153 | + |
| 154 | + var isEmpty = shadowRoot.createAllByXPath(Div.class, "//nonExistentElement").isEmpty(); |
| 155 | + |
| 156 | + var elapsedTime = System.currentTimeMillis() - startTime; |
| 157 | + |
| 158 | + Assertions.assertAll( |
| 159 | + () -> Assertions.assertTrue(isEmpty), |
| 160 | + () -> Assertions.assertTrue(elapsedTime < ConfigurationService.get(WebSettings.class).getTimeoutSettings().getElementWaitTimeout()*1000) |
| 161 | + ); |
| 162 | + } |
| 163 | + |
130 | 164 | // TODO: Test Relative Finding of Elements |
131 | 165 | } |
0 commit comments