public class TestBenchElement extends AbstractHasTestBenchCommandExecutor implements org.openqa.selenium.WrapsElement, org.openqa.selenium.WebElement, TestBenchElementCommands, CanWaitForVaadin, HasDriver, CanCompareScreenshots
| Modifier | Constructor and Description |
|---|---|
protected |
TestBenchElement() |
protected |
TestBenchElement(org.openqa.selenium.WebElement webElement,
TestBenchCommandExecutor tbCommandExecutor) |
| Modifier and Type | Method and Description |
|---|---|
void |
clear() |
void |
click() |
void |
click(int x,
int y,
org.openqa.selenium.Keys... modifiers)
Clicks at the specified coordinates on an element while pressing possible
modifier keys.
|
void |
clickHiddenElement()
Calls the Javascript click method on the element.
|
boolean |
compareScreen(BufferedImage reference,
String referenceName)
Tests that a screen shot is equal to the specified reference image.
|
boolean |
compareScreen(File reference)
Tests that a screen shot is equal to the specified reference image.
|
boolean |
compareScreen(String referenceId)
Tests that a screen shot is equal to the specified reference image.
|
void |
contextClick() |
void |
doubleClick() |
boolean |
equals(Object obj) |
org.openqa.selenium.WebElement |
findElement(org.openqa.selenium.By by) |
List<org.openqa.selenium.WebElement> |
findElements(org.openqa.selenium.By by) |
void |
focus()
Move browser focus to this Element
|
String |
getAccessibleName() |
String |
getAriaRole() |
String |
getAttribute(String name) |
protected org.openqa.selenium.Capabilities |
getCapabilities()
Returns information about current browser used
|
Set<String> |
getClassNames()
Gets all the class names set for this element.
|
TestBenchCommandExecutor |
getCommandExecutor()
Return a reference to the related
TestBenchCommandExecutor
instance. |
org.openqa.selenium.SearchContext |
getContext()
Returns this TestBenchElement cast to a SearchContext.
|
String |
getCssValue(String propertyName) |
String |
getDomAttribute(String name) |
org.openqa.selenium.WebDriver |
getDriver()
Return the
WebDriver instance associated with the implementing
class instance. |
String |
getId()
Returns the id value set for this element.
|
org.openqa.selenium.Point |
getLocation() |
org.openqa.selenium.Rectangle |
getRect() |
<X> X |
getScreenshotAs(org.openqa.selenium.OutputType<X> target) |
org.openqa.selenium.SearchContext |
getShadowRoot() |
org.openqa.selenium.Dimension |
getSize() |
String |
getTagName() |
String |
getText() |
org.openqa.selenium.WebElement |
getWrappedElement() |
boolean |
hasAttribute(String attribute)
Checks if the given attribute is present on the element.
|
boolean |
hasClassName(String className)
Checks if this element has the given class name.
|
int |
hashCode() |
protected void |
init()
This is run after initializing a TestBenchElement.
|
protected void |
init(org.openqa.selenium.WebElement element,
TestBenchCommandExecutor tbCommandExecutor)
TestBenchElement initialization function.
|
protected boolean |
isChrome()
Checks if the current test is running on Chrome.
|
boolean |
isDisplayed() |
boolean |
isEnabled()
Returns whether the Vaadin component, that this element represents, is
enabled or not.
|
protected boolean |
isFirefox()
Checks if the current test is running on Firefox.
|
boolean |
isFocused()
Checks whether the current element is the focused element on the page.
|
boolean |
isReadOnly()
Returns whether the Vaadin component represented by this element has been
set read-only.
|
boolean |
isSelected() |
void |
scroll(int scrollTop)
Sets the number of pixels that an element's content is scrolled from the
top.
|
void |
scrollIntoView()
Scrolls the element into the visible area of the browser window
|
void |
scrollLeft(int scrollLeft)
Sets the number of pixels that an element's content is scrolled to the
left.
|
void |
sendKeys(CharSequence... keysToSend) |
void |
showTooltip()
Shows the tool tip of the specified element.
|
void |
submit() |
void |
waitForVaadin() |
protected <T> T |
waitUntil(org.openqa.selenium.support.ui.ExpectedCondition<T> condition)
Waits up to 10 seconds for the given condition to become neither null nor
false.
|
protected <T> T |
waitUntil(org.openqa.selenium.support.ui.ExpectedCondition<T> condition,
long timeoutInSeconds)
Waits the given number of seconds for the given condition to become
neither null nor false.
|
<T extends AbstractElement> |
wrap(Class<T> elementType)
Decorates the element with the specified Element type, making it possible
to use Vaadin component-specific API on elements found using standard
selenium API.
|
protected static TestBenchElement |
wrapElement(org.openqa.selenium.WebElement element,
TestBenchCommandExecutor tbCommandExecutor) |
protected static List<TestBenchElement> |
wrapElements(List<org.openqa.selenium.WebElement> elements,
TestBenchCommandExecutor tbCommandExecutor) |
$, $$, isElementPresent, isElementPresentprotected TestBenchElement()
protected TestBenchElement(org.openqa.selenium.WebElement webElement,
TestBenchCommandExecutor tbCommandExecutor)
protected void init(org.openqa.selenium.WebElement element,
TestBenchCommandExecutor tbCommandExecutor)
element - WebElement to wraptbCommandExecutor - TestBenchCommandExecutor instanceprotected boolean isChrome()
true if the test is running on Chrome,
false otherwiseprotected boolean isFirefox()
true if the test is running on Firefox,
false otherwiseprotected org.openqa.selenium.Capabilities getCapabilities()
Capabilitiesprotected void init()
public org.openqa.selenium.WebElement getWrappedElement()
getWrappedElement in interface org.openqa.selenium.WrapsElementpublic void waitForVaadin()
waitForVaadin in interface CanWaitForVaadinpublic void showTooltip()
TestBenchElementCommandsshowTooltip in interface TestBenchElementCommandspublic String getId()
public void scroll(int scrollTop)
scroll in interface TestBenchElementCommandsscrollTop - value set to Element.scroll propertyTestBenchElementCommands.scroll(int)public void scrollLeft(int scrollLeft)
scrollLeft in interface TestBenchElementCommandsscrollLeft - value set to Element.scrollLeft propertyTestBenchElementCommands.scrollLeft(int)public boolean isFocused()
true if this element is the currently focused element,
false otherwise.public void click()
click in interface org.openqa.selenium.WebElementpublic void submit()
submit in interface org.openqa.selenium.WebElementpublic void sendKeys(CharSequence... keysToSend)
sendKeys in interface org.openqa.selenium.WebElementpublic void clear()
clear in interface org.openqa.selenium.WebElementpublic String getTagName()
getTagName in interface org.openqa.selenium.WebElementpublic String getDomAttribute(String name)
getDomAttribute in interface org.openqa.selenium.WebElementpublic String getAttribute(String name)
getAttribute in interface org.openqa.selenium.WebElementpublic boolean hasAttribute(String attribute)
attribute - the name of the attributetrue if the attribute is present, false
otherwisepublic String getAriaRole()
getAriaRole in interface org.openqa.selenium.WebElementpublic String getAccessibleName()
getAccessibleName in interface org.openqa.selenium.WebElementpublic boolean isSelected()
isSelected in interface org.openqa.selenium.WebElementpublic boolean isEnabled()
isEnabled in interface org.openqa.selenium.WebElementpublic boolean isReadOnly()
true if the element has the readonly attribute,
false otherwise.public String getText()
getText in interface org.openqa.selenium.WebElementpublic List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
findElements in interface org.openqa.selenium.SearchContextfindElements in interface org.openqa.selenium.WebElementpublic org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
findElement in interface org.openqa.selenium.SearchContextfindElement in interface org.openqa.selenium.WebElementpublic org.openqa.selenium.SearchContext getShadowRoot()
getShadowRoot in interface org.openqa.selenium.WebElementpublic void clickHiddenElement()
public boolean isDisplayed()
isDisplayed in interface org.openqa.selenium.WebElementpublic org.openqa.selenium.Point getLocation()
getLocation in interface org.openqa.selenium.WebElementpublic org.openqa.selenium.Dimension getSize()
getSize in interface org.openqa.selenium.WebElementpublic String getCssValue(String propertyName)
getCssValue in interface org.openqa.selenium.WebElementpublic void click(int x,
int y,
org.openqa.selenium.Keys... modifiers)
TestBenchElementCommandsclick in interface TestBenchElementCommandsx - the offset from the left position of the elementy - the offset from the top position of the elementmodifiers - any modifier keys to press while clicking the element
(optional).public void doubleClick()
public void contextClick()
public <T extends AbstractElement> T wrap(Class<T> elementType)
TestBenchElementCommands
Example:
WebElement e = driver.findElement(By.id("my-table"));
TableElement table = testBenchElement(e).wrap(TableElement.class);
assertEquals("Foo", table.getHeaderCell(1).getText());
wrap in interface TestBenchElementCommandsT - The wrapper element type.elementType - The type (class) containing the API to decorate with. Must
extend
AbstractElement.public TestBenchCommandExecutor getCommandExecutor()
HasTestBenchCommandExecutorTestBenchCommandExecutor
instance.getCommandExecutor in interface HasTestBenchCommandExecutorpublic org.openqa.selenium.WebDriver getDriver()
HasDriverWebDriver instance associated with the implementing
class instance. This can be simply the class itself re-cast as a
WebDriver, or a reference to some WebDriver obtainable by any other
means.public org.openqa.selenium.SearchContext getContext()
getContext in interface HasSearchContextSearchContext instancepublic void focus()
focus in interface TestBenchElementCommandsprotected static List<TestBenchElement> wrapElements(List<org.openqa.selenium.WebElement> elements, TestBenchCommandExecutor tbCommandExecutor)
protected static TestBenchElement wrapElement(org.openqa.selenium.WebElement element, TestBenchCommandExecutor tbCommandExecutor)
public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> target)
throws org.openqa.selenium.WebDriverException
getScreenshotAs in interface org.openqa.selenium.TakesScreenshotorg.openqa.selenium.WebDriverExceptionpublic org.openqa.selenium.Rectangle getRect()
getRect in interface org.openqa.selenium.WebElementpublic Set<String> getClassNames()
public boolean hasClassName(String className)
Matches only full class names, i.e. has ("foo") does not match class="foobar bafoo"
className - the class name to check fortrue if the element has the given class name,
false otherwisepublic boolean compareScreen(String referenceId) throws IOException
CanCompareScreenshotscompareScreen in interface CanCompareScreenshotsreferenceId - the ID of the reference imageIOException - if there was a problem accessing the reference imagepublic boolean compareScreen(File reference) throws IOException
CanCompareScreenshotscompareScreen in interface CanCompareScreenshotsreference - the reference image fileIOException - if there was a problem accessing the reference imagepublic boolean compareScreen(BufferedImage reference, String referenceName) throws IOException
CanCompareScreenshotscompareScreen in interface CanCompareScreenshotsreference - the reference imagereferenceName - the filename of the reference image. Used when writing the
error files.IOException - if there was a problem accessing the reference imagepublic void scrollIntoView()
protected <T> T waitUntil(org.openqa.selenium.support.ui.ExpectedCondition<T> condition,
long timeoutInSeconds)
NotFoundExceptions are ignored by
default.
Use e.g. as
waitUntil(ExpectedConditions.presenceOfElementLocated(by), 10);
T - The return type of the conditioncondition - Models a condition that might reasonably be expected to
eventually evaluate to something that is neither null nor
false.timeoutInSeconds - The timeout in seconds for the wait.org.openqa.selenium.TimeoutException - If the timeout expires.FluentWait.until(java.util.function.Function<? super T, V>),
ExpectedConditionprotected <T> T waitUntil(org.openqa.selenium.support.ui.ExpectedCondition<T> condition)
NotFoundExceptions are ignored by default.
Use e.g. as
waitUntil(ExpectedConditions.presenceOfElementLocated(by));
T - The return type of the conditioncondition - Models a condition that might reasonably be expected to
eventually evaluate to something that is neither null nor
false.org.openqa.selenium.TimeoutException - If 10 seconds passed.FluentWait.until(java.util.function.Function<? super T, V>),
ExpectedConditionCopyright © 2012-2025 Vaadin Ltd. All Rights Reserved.