@Test public void testToString() { when(element1.toString()).thenReturn("element1"); ElementLocator locator = mock(ElementLocator.class); when(locator.findElement()).thenReturn(element1); when(locator.toString()).thenReturn("element1-locator"); WebElement webElement = LocatorProxies.createWebElement(locator); assertThat(webElement.toString()).isEqualTo("element1-locator (Lazy Element)"); assertThat(LocatorProxies.loaded(webElement)).isFalse(); LocatorProxies.now(webElement); assertThat(webElement.toString()).isEqualTo("element1-locator (" + element1.toString() + ")"); }
protected WebElement getElement() { WebElement result; try { if (resolvedElement() != null) { result = resolvedElement(); } else if (locator == null) { result = null; } else { resolvedELement = getLocator().findElement(); if (resolvedELement == null) { throw new ElementNotVisibleException(locator.toString()); } result = resolvedELement; } } catch (Throwable t) { throw t; } return result; }