public class TestBenchElement extends Object implements org.openqa.selenium.internal.WrapsElement, org.openqa.selenium.WebElement, HasDriver, CanCompareScreenshots, HasTestBenchCommandExecutor, HasElementQuery, HasPropertySettersGetters, HasCallFunction
| Modifier | Constructor and Description |
|---|---|
protected |
TestBenchElement() |
protected |
TestBenchElement(org.openqa.selenium.WebElement webElement,
TestBenchCommandExecutor commandExecutor) |
| Modifier and Type | Method and Description |
|---|---|
Object |
callFunction(String methodName,
Object... args)
Invoke the given method on this element using the given arguments as
arguments to the method.
|
void |
clear() |
void |
click() |
void |
click(int x,
int y,
org.openqa.selenium.Keys... modifiers) |
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 |
dispatchEvent(String eventType)
Dispatches (fires) a custom event of the given type on the element.
|
void |
doubleClick() |
boolean |
equals(Object obj) |
protected Object |
executeScript(String script,
Object... args)
Executes the given JavaScript in the context of the currently selected
frame or window.
|
TestBenchElement |
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 |
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) |
org.openqa.selenium.WebDriver |
getDriver()
Return the
WebDriver instance associated with the implementing
class instance. |
org.openqa.selenium.Point |
getLocation() |
Object |
getProperty(String... propertyNames)
Gets a JavaScript property of the given element.
|
Boolean |
getPropertyBoolean(String... propertyNames)
Gets a JavaScript property of the given element as a boolean.
|
Double |
getPropertyDouble(String... propertyNames)
Gets a JavaScript property of the given element as a double.
|
TestBenchElement |
getPropertyElement(String... propertyNames)
Gets a JavaScript property of the given element as a DOM element.
|
List<TestBenchElement> |
getPropertyElements(String... propertyNames)
Gets a JavaScript property of the given element as a list of DOM
elements.
|
Integer |
getPropertyInteger(String... propertyNames)
Gets a JavaScript property of the given element as an integer.
|
String |
getPropertyString(String... propertyNames)
Gets a JavaScript property of the given element as a string.
|
org.openqa.selenium.Rectangle |
getRect() |
<X> X |
getScreenshotAs(org.openqa.selenium.OutputType<X> target) |
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 commandExecutor)
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.
|
protected boolean |
isIE()
Checks if the current test is running on Internet Explorer.
|
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 |
setProperty(String name,
Boolean value)
Sets a JavaScript property of the given element.
|
void |
setProperty(String name,
Double value)
Sets a JavaScript property of the given element.
|
void |
setProperty(String name,
Integer value)
Sets a JavaScript property of the given element.
|
void |
setProperty(String name,
String value)
Sets a JavaScript property of the given element.
|
void |
submit() |
protected 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 TestBenchElement> |
wrap(Class<T> elementType) |
protected static TestBenchElement |
wrapElement(org.openqa.selenium.WebElement element,
TestBenchCommandExecutor commandExecutor) |
protected static List<TestBenchElement> |
wrapElements(List<org.openqa.selenium.WebElement> elements,
TestBenchCommandExecutor commandExecutor) |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait$, $protected TestBenchElement()
protected TestBenchElement(org.openqa.selenium.WebElement webElement,
TestBenchCommandExecutor commandExecutor)
protected void init(org.openqa.selenium.WebElement element,
TestBenchCommandExecutor commandExecutor)
init(), not this function.element - WebElement to wrapcommandExecutor - TestBenchCommandExecutor instanceprotected boolean isChrome()
true if the test is running on Chrome,
false otherwiseprotected boolean isIE()
true if the test is running on Internet Explorer,
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.internal.WrapsElementprotected void waitForVaadin()
public void scroll(int scrollTop)
scrollTop - value set to Element.scroll propertypublic void scrollLeft(int scrollLeft)
scrollLeft - value set to Element.scrollLeft propertypublic 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 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 boolean isSelected()
isSelected in interface org.openqa.selenium.WebElementpublic boolean isEnabled()
isEnabled in interface org.openqa.selenium.WebElementpublic 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 TestBenchElement findElement(org.openqa.selenium.By by)
findElement in interface org.openqa.selenium.SearchContextfindElement in interface org.openqa.selenium.WebElementpublic 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)
public void doubleClick()
public void contextClick()
public <T extends TestBenchElement> T wrap(Class<T> elementType)
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()
protected static List<TestBenchElement> wrapElements(List<org.openqa.selenium.WebElement> elements, TestBenchCommandExecutor commandExecutor)
protected static TestBenchElement wrapElement(org.openqa.selenium.WebElement element, TestBenchCommandExecutor commandExecutor)
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);
condition - 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));
condition - 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>),
ExpectedConditionpublic void setProperty(String name, String value)
HasPropertySettersGetterssetProperty in interface HasPropertySettersGettersname - the name of the propertyvalue - the value to setpublic void setProperty(String name, Boolean value)
HasPropertySettersGetterssetProperty in interface HasPropertySettersGettersname - the name of the propertyvalue - the value to setpublic void setProperty(String name, Double value)
HasPropertySettersGetterssetProperty in interface HasPropertySettersGettersname - the name of the propertyvalue - the value to setpublic void setProperty(String name, Integer value)
HasPropertySettersGetterssetProperty in interface HasPropertySettersGettersname - the name of the propertyvalue - the value to setpublic String getPropertyString(String... propertyNames)
HasPropertySettersGettersgetPropertyString in interface HasPropertySettersGetterspropertyNames - the name of on or more properties, forming a property chain of
type property1.property2.property3public Boolean getPropertyBoolean(String... propertyNames)
HasPropertySettersGettersgetPropertyBoolean in interface HasPropertySettersGetterspropertyNames - the name of on or more properties, forming a property chain of
type property1.property2.property3public TestBenchElement getPropertyElement(String... propertyNames)
HasPropertySettersGettersgetPropertyElement in interface HasPropertySettersGetterspropertyNames - the name of on or more properties, forming a property chain of
type property1.property2.property3public List<TestBenchElement> getPropertyElements(String... propertyNames)
HasPropertySettersGettersgetPropertyElements in interface HasPropertySettersGetterspropertyNames - the name of on or more properties, forming a property chain of
type property1.property2.property3public Double getPropertyDouble(String... propertyNames)
HasPropertySettersGettersgetPropertyDouble in interface HasPropertySettersGetterspropertyNames - the name of on or more properties, forming a property chain of
type property1.property2.property3public Integer getPropertyInteger(String... propertyNames)
HasPropertySettersGettersgetPropertyInteger in interface HasPropertySettersGetterspropertyNames - the name of on or more properties, forming a property chain of
type property1.property2.property3public Object getProperty(String... propertyNames)
HasPropertySettersGettersThe return value needs to be cast manually to the correct type.
getProperty in interface HasPropertySettersGetterspropertyNames - the name of on or more properties, forming a property chain of
type property1.property2.property3protected Object executeScript(String script, Object... args)
This method wraps any returned WebElement as
TestBenchElement.
script - the script to executeargs - the arguments, available in the script as
arguments[0]...arguments[N]JavascriptExecutor.executeScript(String, Object...)
returnsUnsupportedOperationException - if the underlying driver does not support JavaScript
executionJavascriptExecutor.executeScript(String, Object...)public Object callFunction(String methodName, Object... args)
HasCallFunctioncallFunction in interface HasCallFunctionmethodName - the method to invokeargs - the arguments to pass to the methodpublic void dispatchEvent(String eventType)
The event is created without any parameters.
eventType - the type of custom event to dispatchCopyright © 2018. All rights reserved.