From f43ee4609122ea423cd1d7b642f799a8eefa067e Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Tue, 14 Dec 2021 15:48:17 +0200 Subject: [PATCH] Remove unnecessary shadow root helpers --- .../flow/testutil/TestBenchHelpers.java | 56 ------------------- .../flow/navigate/NavigateBetweenViewsIT.java | 19 ++++--- .../vaadin/flow/navigate/ServiceWorkerIT.java | 17 +++--- .../template/AttachExistingElementByIdIT.java | 25 +++++---- .../flow/webcomponent/WebComponentIT.java | 6 +- .../ApplicationThemeComponentIT.java | 3 +- .../flow/uitest/ui/FrontendLiveReloadIT.java | 3 +- .../flow/uitest/ui/JavaLiveReloadIT.java | 25 +++++---- .../ui/PreserveOnRefreshLiveReloadIT.java | 4 +- .../InnerTemplateVisibilityIT.java | 17 +++--- .../flow/uitest/ui/template/EmptyListsIT.java | 5 +- .../ui/template/TemplateScalabilityIT.java | 13 ++--- .../ui/template/imports/LazyWidgetIT.java | 2 +- 13 files changed, 72 insertions(+), 123 deletions(-) diff --git a/flow-test-util/src/main/java/com/vaadin/flow/testutil/TestBenchHelpers.java b/flow-test-util/src/main/java/com/vaadin/flow/testutil/TestBenchHelpers.java index 52a8b041d13..506d925fbff 100644 --- a/flow-test-util/src/main/java/com/vaadin/flow/testutil/TestBenchHelpers.java +++ b/flow-test-util/src/main/java/com/vaadin/flow/testutil/TestBenchHelpers.java @@ -189,52 +189,6 @@ protected static void assertEquals(WebElement expectedElement, Assert.assertEquals(unwrappedExpected, unwrappedActual); } - /** - * Returns true if a component can be found with given By - * selector in the shadow DOM of the {@code webComponent}. - * - * @param webComponent - * the web component owning shadow DOM to start search from - * @param by - * the selector used to find element - * @return true if the component can be found - */ - protected boolean isPresentInShadowRoot(WebElement webComponent, By by) { - return !findInShadowRoot(webComponent, by).isEmpty(); - } - - /** - * Find the first {@link WebElement} using the given {@link By} selector. - * - * @param shadowRootOwner - * the web component owning shadow DOM to start search from - * @param by - * the selector used to find element - * @return an element from shadow root, if located - * @throws AssertionError - * if shadow root is not present or element is not found in the - * shadow root - */ - protected WebElement getInShadowRoot(WebElement shadowRootOwner, By by) { - return getShadowRoot(shadowRootOwner).findElements(by).stream() - .findFirst().orElseThrow(() -> new AssertionError( - "Could not find required element in the shadowRoot")); - } - - /** - * Find all {@link WebElement}s using the given {@link By} selector. - * - * @param webComponent - * the web component owning shadow DOM to start search from - * @param by - * the selector used to find elements - * @return a list of found elements - */ - protected List findInShadowRoot(WebElement webComponent, - By by) { - return getShadowRoot(webComponent).findElements(by); - } - /** * Executes the given JavaScript. *

@@ -419,16 +373,6 @@ protected void waitForDevServer() { } while (Boolean.TRUE.equals(result)); } - private WebElement getShadowRoot(WebElement webComponent) { - waitUntil(driver -> getCommandExecutor().executeScript( - "return arguments[0].shadowRoot", webComponent) != null); - WebElement shadowRoot = (WebElement) getCommandExecutor() - .executeScript("return arguments[0].shadowRoot", webComponent); - Assert.assertNotNull("Could not locate shadowRoot in the element", - shadowRoot); - return shadowRoot; - } - /** * Calls the {@code blur()} function on the current active element of the * page, if any. diff --git a/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/NavigateBetweenViewsIT.java b/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/NavigateBetweenViewsIT.java index 2cd948c5e6c..4b857372a1d 100644 --- a/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/NavigateBetweenViewsIT.java +++ b/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/NavigateBetweenViewsIT.java @@ -23,6 +23,7 @@ import com.vaadin.flow.component.html.testbench.NativeButtonElement; import com.vaadin.flow.component.html.testbench.SpanElement; import com.vaadin.flow.testutil.ChromeBrowserTest; +import com.vaadin.testbench.TestBenchElement; import static com.vaadin.flow.navigate.HelloWorldView.IS_CONNECTED_ON_ATTACH; import static com.vaadin.flow.navigate.HelloWorldView.IS_CONNECTED_ON_INIT; @@ -47,8 +48,9 @@ public void openFlowView_navigateToTsView_navigationSuccessful() { Assert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/about")); - Assert.assertTrue(getInShadowRoot(findElement(By.tagName("about-view")), - By.id("navigate-hello")).isDisplayed()); + TestBenchElement aboutView = $("about-view").first(); + + Assert.assertTrue(aboutView.$("*").id("navigate-hello").isDisplayed()); } @Test @@ -61,8 +63,8 @@ public void openTsView_navigateToFlow_navigationSuccessful() { waitUntil(input -> $("about-view").first().$("a").id("navigate-hello") .isDisplayed()); - getInShadowRoot(findElement(By.tagName("about-view")), - By.id("navigate-hello")).click(); + TestBenchElement aboutView = $("about-view").first(); + aboutView.$("*").id("navigate-hello").click(); getCommandExecutor().waitForVaadin(); @@ -88,8 +90,9 @@ public void openFlowView_isConnectedOnAttach() { waitUntil(input -> $("about-view").first().$("a").id("navigate-hello") .isDisplayed()); - getInShadowRoot(findElement(By.tagName("about-view")), - By.id("navigate-hello")).click(); + TestBenchElement aboutView = $("about-view").first(); + + aboutView.$("*").id("navigate-hello").click(); assertIsConnected(); } @@ -102,8 +105,8 @@ public void openTsView_navigateToFlowView_isConnectedOnAttach() { waitUntil(input -> $("about-view").first().$("a").id("navigate-hello") .isDisplayed()); - getInShadowRoot(findElement(By.tagName("about-view")), - By.id("navigate-hello")).click(); + TestBenchElement aboutView = $("about-view").first(); + aboutView.$("*").id("navigate-hello").click(); getCommandExecutor().waitForVaadin(); diff --git a/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/ServiceWorkerIT.java b/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/ServiceWorkerIT.java index 38a5f4ae0bf..f5e02dbe573 100644 --- a/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/ServiceWorkerIT.java +++ b/flow-tests/test-ccdm-flow-navigation/src/test/java/com/vaadin/flow/navigate/ServiceWorkerIT.java @@ -27,6 +27,7 @@ import org.openqa.selenium.mobile.NetworkConnection; import com.vaadin.flow.testutil.ChromeDeviceTest; +import com.vaadin.testbench.TestBenchElement; import elemental.json.Json; import elemental.json.JsonObject; @@ -114,9 +115,9 @@ public void offlineNonRoot_reload_viewReloaded() throws IOException { MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/another")); + TestBenchElement anotherView = $("another-view").first(); Assert.assertTrue( - getInShadowRoot(findElement(By.tagName("another-view")), - By.id("another-content")).isDisplayed()); + anotherView.$("*").id("another-content").isDisplayed()); } finally { // Reset network conditions back setConnectionType(NetworkConnection.ConnectionType.ALL); @@ -149,9 +150,9 @@ public void offlineDeepPath_reload_viewReloaded_baseUrlRewritten() MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/another")); + TestBenchElement anotherView = $("another-view").first(); Assert.assertTrue( - getInShadowRoot(findElement(By.tagName("another-view")), - By.id("another-content")).isDisplayed()); + anotherView.$("*").id("another-content").isDisplayed()); // Verify by navigating with a relative link $("main-view").first().$("a").id("menu-about").click(); @@ -189,9 +190,9 @@ public void offlineTsView_navigateToOtherTsView_navigationSuccessful() MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/another")); + TestBenchElement anotherView = $("another-view").first(); Assert.assertTrue( - getInShadowRoot(findElement(By.tagName("another-view")), - By.id("another-content")).isDisplayed()); + anotherView.$("*").id("another-content").isDisplayed()); } finally { // Reset network conditions back setConnectionType(NetworkConnection.ConnectionType.ALL); @@ -218,9 +219,9 @@ public void offlineServerView_navigateToTsView_navigationSuccessful() MatcherAssert.assertThat(getDriver().getCurrentUrl(), CoreMatchers.endsWith("/another")); + TestBenchElement anotherView = $("another-view").first(); Assert.assertTrue( - getInShadowRoot(findElement(By.tagName("another-view")), - By.id("another-content")).isDisplayed()); + anotherView.$("*").id("another-content").isDisplayed()); } finally { // Reset network conditions back setConnectionType(NetworkConnection.ConnectionType.ALL); diff --git a/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AttachExistingElementByIdIT.java b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AttachExistingElementByIdIT.java index 9d23117e3dd..b030d923bc1 100644 --- a/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AttachExistingElementByIdIT.java +++ b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AttachExistingElementByIdIT.java @@ -15,15 +15,14 @@ */ package com.vaadin.flow.uitest.ui.template; +import com.vaadin.flow.testutil.ChromeBrowserTest; +import com.vaadin.testbench.TestBenchElement; + import org.junit.Assert; import org.junit.Test; -import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; -import com.vaadin.flow.testutil.ChromeBrowserTest; -import com.vaadin.testbench.TestBenchElement; - public class AttachExistingElementByIdIT extends ChromeBrowserTest { @Test @@ -39,29 +38,31 @@ private void assertTemplate(String id) { private void assertTemplate(String id, String initialLabelText, String placeholder) { - WebElement input = getInput(id); + TestBenchElement template = $("*").id(id); + WebElement input = getInput(template); - Assert.assertEquals(initialLabelText, getLabel(id).getText()); + Assert.assertEquals(initialLabelText, getLabel(template).getText()); Assert.assertEquals(placeholder, input.getAttribute("placeholder")); input.sendKeys("Harley!"); input.sendKeys(Keys.ENTER); - Assert.assertEquals("Text from input Harley!", getLabel(id).getText()); + Assert.assertEquals("Text from input Harley!", + getLabel(template).getText()); // Reset values to defaults $(TestBenchElement.class).id(id).$(TestBenchElement.class).id("button") .click(); - Assert.assertEquals("default", getLabel(id).getText()); + Assert.assertEquals("default", getLabel(template).getText()); } - private WebElement getInput(String id) { - return getInShadowRoot(findElement(By.id(id)), By.id("input")); + private WebElement getInput(TestBenchElement template) { + return template.$("*").id("input"); } - private WebElement getLabel(String id) { - return getInShadowRoot(findElement(By.id(id)), By.id("label")); + private WebElement getLabel(TestBenchElement template) { + return template.$("*").id("label"); } } diff --git a/flow-tests/test-embedding/embedding-test-assets/src/test/java/com/vaadin/flow/webcomponent/WebComponentIT.java b/flow-tests/test-embedding/embedding-test-assets/src/test/java/com/vaadin/flow/webcomponent/WebComponentIT.java index 4cacfde88b5..978c579cbde 100644 --- a/flow-tests/test-embedding/embedding-test-assets/src/test/java/com/vaadin/flow/webcomponent/WebComponentIT.java +++ b/flow-tests/test-embedding/embedding-test-assets/src/test/java/com/vaadin/flow/webcomponent/WebComponentIT.java @@ -37,8 +37,7 @@ public void indexPageGetsWebComponent_attributeIsReflectedToServer() { waitForElementVisible(By.id("show-message")); TestBenchElement showMessage = byId("show-message"); - waitUntil(driver -> isPresentInShadowRoot(showMessage, - By.tagName("select"))); + waitUntil(driver -> showMessage.$("select").exists()); TestBenchElement select = showMessage.$("select").first(); // Selection is visibly changed and event manually dispatched @@ -69,7 +68,8 @@ public void downloadLinkHasCorrectBaseURL() { waitForElementVisible(By.id("show-message")); TestBenchElement showMessage = byId("show-message"); - waitUntil(driver -> isPresentInShadowRoot(showMessage, By.id("link"))); + waitUntil( + driver -> showMessage.$("*").attribute("id", "link").exists()); TestBenchElement link = showMessage.$("a").id("link"); String href = link.getAttribute("href"); // self check diff --git a/flow-tests/test-embedding/test-embedding-application-theme/src/test/java/com/vaadin/flow/webcomponent/ApplicationThemeComponentIT.java b/flow-tests/test-embedding/test-embedding-application-theme/src/test/java/com/vaadin/flow/webcomponent/ApplicationThemeComponentIT.java index 1d5b20ea92d..61ddbd4ad86 100644 --- a/flow-tests/test-embedding/test-embedding-application-theme/src/test/java/com/vaadin/flow/webcomponent/ApplicationThemeComponentIT.java +++ b/flow-tests/test-embedding/test-embedding-application-theme/src/test/java/com/vaadin/flow/webcomponent/ApplicationThemeComponentIT.java @@ -199,8 +199,7 @@ public void stylesCssImport_externalLinkAddedToShadowroot() { open(); checkLogsForErrors(); final TestBenchElement themedComponent = $("themed-component").first(); - final List links = findInShadowRoot(themedComponent, - By.tagName("link")); + final List links = themedComponent.$("link").all(); List linkUrls = links.stream() .map(link -> link.getAttribute("href")) diff --git a/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/FrontendLiveReloadIT.java b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/FrontendLiveReloadIT.java index 2dadca0f528..89f012bcce2 100644 --- a/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/FrontendLiveReloadIT.java +++ b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/FrontendLiveReloadIT.java @@ -59,8 +59,7 @@ public void liveReloadOnTouchedFrontendFile() { // then: the frontend changes are visible in the DOM WebElement customComponent = findElement( By.id(FrontendLiveReloadView.CUSTOM_COMPONENT)); - WebElement embeddedDiv = findInShadowRoot(customComponent, - By.id("custom-div")).get(0); + WebElement embeddedDiv = customComponent.$("*").id("custom-div"); Assert.assertEquals("Updated component contents", embeddedDiv.getText()); } diff --git a/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/JavaLiveReloadIT.java b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/JavaLiveReloadIT.java index 8e9e10718a0..71cfa422e3f 100644 --- a/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/JavaLiveReloadIT.java +++ b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/JavaLiveReloadIT.java @@ -40,20 +40,20 @@ public void overlayShouldRender() { Assert.assertEquals(1, liveReloads.size()); WebElement liveReload = liveReloads.get(0); - WebElement window = findInShadowRoot(liveReload, By.className("window")) - .get(0); + WebElement window = liveReload.$("*") + .attributeContains("class", "window").first(); Assert.assertFalse(window.isDisplayed()); // After clicking the icon in the indicator, the live-reload message // window should appear - WebElement liveReloadIcon = findInShadowRoot(liveReload, - By.className("gizmo")).get(0); + WebElement liveReloadIcon = liveReload.$("*") + .attributeContains("class", "gizmo").first(); liveReloadIcon.click(); waitForElementPresent(By.tagName("vaadin-devmode-gizmo")); - WebElement window2 = findInShadowRoot(liveReload, By.className("gizmo")) - .get(0); + WebElement window2 = liveReload.$("*") + .attributeContains("class", "gizmo").first(); Assert.assertTrue(window2.isDisplayed()); } @@ -69,8 +69,9 @@ public void splashMessageShownOnAutoReloadAndClosedOnBodyClick() { WebElement liveReload = findElement(By.tagName("vaadin-devmode-gizmo")); Assert.assertNotNull(liveReload); - WebElement gizmo1 = findInShadowRoot(liveReload, By.className("gizmo")) - .get(0); + WebElement gizmo1 = liveReload.$("*") + .attributeContains("class", "gizmo").first(); + Assert.assertTrue(gizmo1.getAttribute("class").contains("active")); findElement(By.tagName("body")).click(); @@ -78,8 +79,8 @@ public void splashMessageShownOnAutoReloadAndClosedOnBodyClick() { WebElement liveReload2 = findElement( By.tagName("vaadin-devmode-gizmo")); Assert.assertNotNull(liveReload2); - WebElement gizmo2 = findInShadowRoot(liveReload2, By.className("gizmo")) - .get(0); + WebElement gizmo2 = liveReload2.$("*") + .attributeContains("class", "gizmo").first(); Assert.assertFalse(gizmo2.getAttribute("class").contains("active")); Assert.assertTrue(gizmo2.getAttribute("class").contains("gizmo")); } @@ -101,8 +102,8 @@ public void deactivateLiveReload() { // then: page is not reloaded WebElement liveReload2 = findElement( By.tagName("vaadin-devmode-gizmo")); - WebElement gizmo2 = findInShadowRoot(liveReload2, By.className("gizmo")) - .get(0); + WebElement gizmo2 = liveReload2.$("*") + .attributeContains("class", "gizmo").first(); Assert.assertFalse(gizmo2.getAttribute("class").contains("active")); Assert.assertTrue(gizmo2.getAttribute("class").contains("gizmo")); } diff --git a/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/PreserveOnRefreshLiveReloadIT.java b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/PreserveOnRefreshLiveReloadIT.java index 433d872a9cb..0c84a757bf6 100644 --- a/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/PreserveOnRefreshLiveReloadIT.java +++ b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/PreserveOnRefreshLiveReloadIT.java @@ -30,8 +30,8 @@ public void notificationShownWhenLoadingPreserveOnRefreshView() { WebElement liveReload = findElement(By.tagName("vaadin-devmode-gizmo")); Assert.assertNotNull(liveReload); - WebElement messageDetails = findInShadowRoot(liveReload, - By.className("warning")).get(0); + WebElement messageDetails = liveReload.$("*") + .attributeContains("class", "warning").first(); Assert.assertTrue( messageDetails.getText().contains("@PreserveOnRefresh")); } diff --git a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/littemplate/InnerTemplateVisibilityIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/littemplate/InnerTemplateVisibilityIT.java index 7cc375c99ba..45966dc4355 100644 --- a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/littemplate/InnerTemplateVisibilityIT.java +++ b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/littemplate/InnerTemplateVisibilityIT.java @@ -7,6 +7,7 @@ import com.vaadin.flow.component.html.testbench.NativeButtonElement; import com.vaadin.flow.testutil.ChromeBrowserTest; +import com.vaadin.testbench.TestBenchElement; public class InnerTemplateVisibilityIT extends ChromeBrowserTest { @@ -21,10 +22,10 @@ public void innerTemplateIsHiddenWithDisplayNone() { // then: element is not visible, attribute 'hidden' and 'display: none' // set - WebElement outer = findElement( - By.id(InnerTemplateVisibilityView.OUTER_ID)); - WebElement inner = findInShadowRoot(outer, - By.id(InnerTemplateVisibilityView.INNER_ID)).get(0); + TestBenchElement outer = $("*") + .id(InnerTemplateVisibilityView.OUTER_ID); + TestBenchElement inner = outer.$("*") + .id(InnerTemplateVisibilityView.INNER_ID); Assert.assertFalse("expected inner to be hidden", inner.isDisplayed()); Assert.assertNotNull("expected attribute hidden on inner", inner.getAttribute("hidden")); @@ -44,10 +45,10 @@ public void innerTemplateDisplayStyleRestored() { // then: element is visible, attribute and 'display: none' are no longer // present - WebElement outer = findElement( - By.id(InnerTemplateVisibilityView.OUTER_ID)); - WebElement inner = findInShadowRoot(outer, - By.id(InnerTemplateVisibilityView.INNER_ID)).get(0); + TestBenchElement outer = $("*") + .id(InnerTemplateVisibilityView.OUTER_ID); + TestBenchElement inner = outer.$("*") + .id(InnerTemplateVisibilityView.INNER_ID); Assert.assertTrue("expected inner to be visible", inner.isDisplayed()); Assert.assertNull("inner should not have attribute hidden", inner.getAttribute("hidden")); diff --git a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/EmptyListsIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/EmptyListsIT.java index 22f049f26a6..7a97c0bddbb 100644 --- a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/EmptyListsIT.java +++ b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/EmptyListsIT.java @@ -27,6 +27,7 @@ import org.openqa.selenium.logging.LogEntry; import com.vaadin.flow.testutil.ChromeBrowserTest; +import com.vaadin.testbench.TestBenchElement; public class EmptyListsIT extends ChromeBrowserTest { @@ -34,10 +35,10 @@ public class EmptyListsIT extends ChromeBrowserTest { public void emptyListsAreProperlyHandled() { open(); - WebElement template = findElement(By.id("template")); + TestBenchElement template = $("*").id("template"); Assert.assertTrue( - isPresentInShadowRoot(template, By.className("item"))); + template.$("*").attributeContains("class", "item").exists()); findElement(By.id("set-empty")).click(); diff --git a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/TemplateScalabilityIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/TemplateScalabilityIT.java index d8272ba06ef..bc7c42fc95d 100644 --- a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/TemplateScalabilityIT.java +++ b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/TemplateScalabilityIT.java @@ -16,15 +16,14 @@ public void openPage_allButtonsRenderSuccessfully() { open(); waitUntil(input -> { - return !findInShadowRoot( - input.findElement(By.id("scalability-view")), - By.id(TemplateScalabilityView.COMPLETED)).isEmpty(); + TestBenchElement view = $("*").id("scalability-view"); + return view.$("*") + .attribute("id", TemplateScalabilityView.COMPLETED) + .exists(); }); - WebElement viewTemplate = getDriver() - .findElement(By.id("scalability-view")); - int buttons = findInShadowRoot(viewTemplate, - By.tagName("template-scalability-panel")).size(); + TestBenchElement viewTemplate = $("*").id("scalability-view"); + int buttons = viewTemplate.$("template-scalability-panel").all().size(); Assert.assertEquals("Template should have created " + TemplateScalabilityView.NUM_ITEMS + " panels with buttons.", diff --git a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/imports/LazyWidgetIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/imports/LazyWidgetIT.java index 149daab35ab..79ded4001ae 100644 --- a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/imports/LazyWidgetIT.java +++ b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/imports/LazyWidgetIT.java @@ -42,7 +42,7 @@ public void lazyLoadedPolymerTemplateWorksAsElement() { String input = "InputMaster"; Assert.assertFalse( "No greeting should be present before we press the button", - isPresentInShadowRoot(template, By.id("greeting"))); + template.$("*").attribute("id", "greeting").exists()); template.$(TestBenchElement.class).id("input").sendKeys(input); template.$(TestBenchElement.class).id("button").click();