From c67a8c03812916314239886cd3074a8ab6cfa6f0 Mon Sep 17 00:00:00 2001 From: Zhe Sun <31067185+ZheSun88@users.noreply.github.com> Date: Mon, 20 Dec 2021 08:56:33 +0200 Subject: [PATCH] test: Remove unnecessary shadow root helpers (#12573) (#12601) Co-authored-by: Artur --- .../flow/testutil/TestBenchHelpers.java | 56 ------------------- .../AbstractAttachExistingElementByIdIT.java | 8 +-- .../BundledTemplateInTemplateWithIdIT.java | 7 ++- .../flow/webcomponent/WebComponentIT.java | 6 +- .../ApplicationThemeComponentIT.java | 3 +- .../vaadin/flow/uitest/ui/LiveReloadIT.java | 47 ++++++++-------- .../ui/PreserveOnRefreshLiveReloadIT.java | 8 +-- .../flow/uitest/ui/template/EmptyListsIT.java | 5 +- .../template/InnerTemplateVisibilityIT.java | 17 +++--- .../ui/template/TemplateScalabilityIT.java | 13 ++--- .../ui/template/imports/LazyWidgetIT.java | 2 +- .../uitest/ui/template/ThemedTemplateIT.java | 31 ++++++---- .../flow/uitest/ui/theme/MyThemeIT.java | 7 ++- 13 files changed, 80 insertions(+), 130 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 c81580b813a..6fc356a2c80 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 @@ -182,52 +182,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. *

@@ -413,16 +367,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-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AbstractAttachExistingElementByIdIT.java b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AbstractAttachExistingElementByIdIT.java index dbb7c711a71..170b976c96f 100644 --- a/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AbstractAttachExistingElementByIdIT.java +++ b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/AbstractAttachExistingElementByIdIT.java @@ -46,11 +46,11 @@ protected void assertTemplate(String id, String initialLabelText, Assert.assertEquals("default", getLabel(id).getText()); } - protected WebElement getInput(String id) { - return getInShadowRoot(findElement(By.id(id)), By.id("input")); + protected TestBenchElement getInput(String id) { + return $("*").id(id).$("*").id("input"); } - protected WebElement getLabel(String id) { - return getInShadowRoot(findElement(By.id(id)), By.id("label")); + protected TestBenchElement getLabel(String id) { + return $("*").id(id).$("*").id("label"); } } diff --git a/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/BundledTemplateInTemplateWithIdIT.java b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/BundledTemplateInTemplateWithIdIT.java index 772adda01a4..b6fbb0902f5 100644 --- a/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/BundledTemplateInTemplateWithIdIT.java +++ b/flow-tests/test-dev-mode/src/test/java/com/vaadin/flow/uitest/ui/template/BundledTemplateInTemplateWithIdIT.java @@ -15,6 +15,7 @@ */ package com.vaadin.flow.uitest.ui.template; +import com.vaadin.testbench.TestBenchElement; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; @@ -28,10 +29,10 @@ public class BundledTemplateInTemplateWithIdIT extends ChromeBrowserTest { public void childTemplateInstanceHandlesEvent() { open(); - WebElement template = findElement(By.id("template")); - WebElement child = getInShadowRoot(template, By.id("child")); + TestBenchElement template = $("*").id("template"); + TestBenchElement child = template.$("*").id("child"); - WebElement text = getInShadowRoot(child, By.id("text")); + WebElement text = child.$("*").id("text"); Assert.assertEquals("div", text.getTagName()); Assert.assertEquals("@Id injected!", text.getText()); } 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 67616bfe295..27b1f2a6a1a 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 @@ -40,8 +40,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 @@ -72,7 +71,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 847cfecddde..bc1eec6ebfa 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 @@ -210,8 +210,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/LiveReloadIT.java b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/LiveReloadIT.java index 6d996a6dc27..7373192af61 100644 --- a/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/LiveReloadIT.java +++ b/flow-tests/test-live-reload/src/test/java/com/vaadin/flow/uitest/ui/LiveReloadIT.java @@ -17,6 +17,7 @@ import java.util.List; +import com.vaadin.testbench.TestBenchElement; import net.jcip.annotations.NotThreadSafe; import org.junit.Assert; import org.junit.Test; @@ -32,25 +33,24 @@ public void overlayShouldRender() { // Upon opening, the LiveReloadUI should show the indicator but not the // message window waitForElementPresent(By.tagName("vaadin-devmode-gizmo")); - List liveReloads = findElements( - By.tagName("vaadin-devmode-gizmo")); + List liveReloads = $("vaadin-devmode-gizmo").all(); Assert.assertEquals(1, liveReloads.size()); - WebElement liveReload = liveReloads.get(0); + TestBenchElement 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()); } @@ -62,20 +62,19 @@ public void splashMessageShownOnAutoReloadAndClosedOnBodyClick() { By.id(LiveReloadView.JAVA_LIVE_RELOAD_TRIGGER_BUTTON)); liveReloadTrigger.click(); - WebElement liveReload = findElement(By.tagName("vaadin-devmode-gizmo")); + TestBenchElement liveReload = $("vaadin-devmode-gizmo").first(); 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(); - WebElement liveReload2 = findElement( - By.tagName("vaadin-devmode-gizmo")); + TestBenchElement liveReload2 = $("vaadin-devmode-gizmo").first(); 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")); @@ -87,14 +86,13 @@ public void deactivateLiveReload() { // given: live reload is deactivated waitForElementPresent(By.tagName("vaadin-devmode-gizmo")); - WebElement liveReload = findElement(By.tagName("vaadin-devmode-gizmo")); + TestBenchElement liveReload = $("vaadin-devmode-gizmo").first(); - WebElement liveReloadIcon = findInShadowRoot(liveReload, - By.className("gizmo")).get(0); + WebElement liveReloadIcon = liveReload.$("*") + .attributeContains("class", "gizmo").first(); liveReloadIcon.click(); - WebElement deactivateCheckbox = findInShadowRoot(liveReload, - By.id("toggle")).get(0); + WebElement deactivateCheckbox = liveReload.$("*").id("toggle"); deactivateCheckbox.click(); // when: live reload is triggered @@ -103,10 +101,9 @@ public void deactivateLiveReload() { liveReloadTrigger.click(); // then: page is not reloaded - WebElement liveReload2 = findElement( - By.tagName("vaadin-devmode-gizmo")); - WebElement gizmo2 = findInShadowRoot(liveReload2, By.className("gizmo")) - .get(0); + TestBenchElement liveReload2 = $("vaadin-devmode-gizmo").first(); + 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 c1a04f915c1..1aa37596054 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 @@ -15,10 +15,10 @@ */ package com.vaadin.flow.uitest.ui; +import com.vaadin.testbench.TestBenchElement; import net.jcip.annotations.NotThreadSafe; import org.junit.Assert; import org.junit.Test; -import org.openqa.selenium.By; import org.openqa.selenium.WebElement; @NotThreadSafe @@ -28,10 +28,10 @@ public class PreserveOnRefreshLiveReloadIT extends AbstractLiveReloadIT { public void notificationShownWhenLoadingPreserveOnRefreshView() { open(); - WebElement liveReload = findElement(By.tagName("vaadin-devmode-gizmo")); + TestBenchElement liveReload = $("vaadin-devmode-gizmo").first(); 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/template/EmptyListsIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/EmptyListsIT.java index 1c08416ed5e..04973471c94 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/InnerTemplateVisibilityIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/InnerTemplateVisibilityIT.java index ddfe76fbfa3..f400453d5e2 100644 --- a/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/InnerTemplateVisibilityIT.java +++ b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/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/TemplateScalabilityIT.java b/flow-tests/test-root-context/src/test/java/com/vaadin/flow/uitest/ui/template/TemplateScalabilityIT.java index 9d8168d4142..cb4c0ee3f96 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 a08b7533e1f..1c11111faef 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(); diff --git a/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/template/ThemedTemplateIT.java b/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/template/ThemedTemplateIT.java index de7efe15d0c..00d361576be 100644 --- a/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/template/ThemedTemplateIT.java +++ b/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/template/ThemedTemplateIT.java @@ -22,6 +22,8 @@ import java.util.Set; import java.util.stream.Collectors; +import com.vaadin.testbench.TestBenchElement; +import com.vaadin.testbench.commands.CanCompareScreenshots; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; @@ -36,22 +38,22 @@ public void themedUrlsAreAdded() { open(); // check that all imported templates are available in the DOM - WebElement template = findElement(By.tagName("themed-template")); + TestBenchElement template = $("themed-template").first(); - Assert.assertTrue("The main template has no simple child Div inside it", - isPresentInShadowRoot(template, By.id("div"))); - Assert.assertTrue( - "The main template has no sub template which is imported by " + Assert.assertNotNull("The main template has no simple child Div inside it", + isPresentInShadowRoot(template, "div")); + + Assert.assertNotNull("The main template has no sub template which is imported by " + "relative URL referring to the resource in the same folder", - isPresentInShadowRoot(template, By.id("relative1"))); - Assert.assertTrue( - "The main template has no sub template which is imported by " + isPresentInShadowRoot(template, "relative1")); + + Assert.assertNotNull("The main template has no sub template which is imported by " + "relative URL referring to the resource in the parent folder", - isPresentInShadowRoot(template, By.id("relative2"))); - Assert.assertTrue( - "The main template has no sub template which is imported by " + isPresentInShadowRoot(template, "relative2")); + + Assert.assertNotNull("The main template has no sub template which is imported by " + "absolute URL", - isPresentInShadowRoot(template, By.id("absolute"))); + isPresentInShadowRoot(template, "absolute")); WebElement head = findElement(By.tagName("head")); List links = head.findElements(By.tagName("link")); @@ -89,4 +91,9 @@ private String getFilePath(String url) { e); } } + + private TestBenchElement isPresentInShadowRoot(TestBenchElement template, String id){ + TestBenchElement element = template.$("*").id(id); + return element; + } } diff --git a/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/theme/MyThemeIT.java b/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/theme/MyThemeIT.java index 986a5f1f4c4..d4c744e991d 100644 --- a/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/theme/MyThemeIT.java +++ b/flow-tests/test-themes-legacy/src/test/java/com/vaadin/flow/uitest/ui/theme/MyThemeIT.java @@ -15,6 +15,7 @@ */ package com.vaadin.flow.uitest.ui.theme; +import com.vaadin.testbench.TestBenchElement; import org.junit.Assert; import org.junit.Test; import org.openqa.selenium.By; @@ -29,9 +30,9 @@ public void loadBaseComponent() { getDriver().get(getRootURL() + "/view/com.vaadin.flow.uitest.ui.theme.MyComponentView"); - WebElement element = findElement(By.tagName("my-component")); - Assert.assertFalse( - findInShadowRoot(element, By.id("component")).isEmpty()); + TestBenchElement element = $("my-component").first(); + + Assert.assertNotNull("Couldn't find element.", element.$("*").id("component")); } @Test