public abstract class TestBenchTestCase extends AbstractHasTestBenchCommandExecutor implements HasDriver
| Modifier and Type | Field and Description |
|---|---|
protected org.openqa.selenium.WebDriver |
driver |
RetryRule |
maxAttempts
Specifies retry count, which is used to run same test several times.
|
| Constructor and Description |
|---|
TestBenchTestCase() |
| Modifier and Type | Method and Description |
|---|---|
protected String |
concatUrl(String baseUrl,
String uri)
Combines a base URL with an URI to create a final URL.
|
protected Object |
executeScript(String script,
Object... args)
Executes the given JavaScript in the context of the currently selected
frame or window.
|
org.openqa.selenium.WebElement |
findElement(org.openqa.selenium.By by) |
List<org.openqa.selenium.WebElement> |
findElements(org.openqa.selenium.By by) |
TestBenchCommandExecutor |
getCommandExecutor()
Return a reference to the related
TestBenchCommandExecutor
instance. |
org.openqa.selenium.SearchContext |
getContext()
Get a reference or a new instance of the SearchContext applicable to this
class
|
org.openqa.selenium.WebDriver |
getDriver()
Returns the
WebDriver instance previously specified by
setDriver(org.openqa.selenium.WebDriver), or (if the previously
provided WebDriver instance was not already a
TestBenchDriverProxy instance) a TestBenchDriverProxy
that wraps that driver. |
void |
setDriver(org.openqa.selenium.WebDriver driver)
Sets the active
WebDriver that is used by this this case |
TestBenchCommands |
testBench()
Convenience method the return
TestBenchCommands for the default
WebDriver instance. |
static TestBenchCommands |
testBench(org.openqa.selenium.WebDriver webDriver)
Convenience method that casts the specified
WebDriver instance to
an instance of TestBenchCommands, making it easy to access the
special TestBench commands. |
TestBenchElementCommands |
testBenchElement(org.openqa.selenium.WebElement webElement)
Convenience method that casts the specified
WebElement instance
to an instance of TestBenchElementCommands, making it easy to
access the special TestBench commands. |
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,
java.time.Duration duration)
Waits the given duration for the given condition to become neither null
nor false.
|
protected <T> T |
waitUntil(org.openqa.selenium.support.ui.ExpectedCondition<T> condition,
long timeoutInSeconds)
Deprecated.
Use
waitUntil(ExpectedCondition, Duration) instead |
<T extends AbstractElement> |
wrap(Class<T> elementType,
org.openqa.selenium.WebElement element)
Decorates the element with the specified Element type, making it possible
to use Vaadin component-specific API on elements found using standard
selenium API.
|
$, $$, isElementPresent, isElementPresentpublic RetryRule maxAttempts
protected org.openqa.selenium.WebDriver driver
public static TestBenchCommands testBench(org.openqa.selenium.WebDriver webDriver)
WebDriver instance to
an instance of TestBenchCommands, making it easy to access the
special TestBench commands.webDriver - The WebDriver instance to cast.public TestBenchCommands testBench()
TestBenchCommands for the default
WebDriver instance.public TestBenchElementCommands testBenchElement(org.openqa.selenium.WebElement webElement)
WebElement instance
to an instance of TestBenchElementCommands, making it easy to
access the special TestBench commands.webElement - The WebElement to cast.protected String concatUrl(String baseUrl, String uri)
baseUrl - the base URLuri - the URIpublic org.openqa.selenium.WebDriver getDriver()
WebDriver instance previously specified by
setDriver(org.openqa.selenium.WebDriver), or (if the previously
provided WebDriver instance was not already a
TestBenchDriverProxy instance) a TestBenchDriverProxy
that wraps that driver.public void setDriver(org.openqa.selenium.WebDriver driver)
WebDriver that is used by this this casedriver - The WebDriver instance to set.public org.openqa.selenium.SearchContext getContext()
HasSearchContextgetContext in interface HasSearchContextSearchContext instancepublic TestBenchCommandExecutor getCommandExecutor()
HasTestBenchCommandExecutorTestBenchCommandExecutor
instance.getCommandExecutor in interface HasTestBenchCommandExecutorpublic org.openqa.selenium.WebElement findElement(org.openqa.selenium.By by)
public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
public <T extends AbstractElement> T wrap(Class<T> elementType, org.openqa.selenium.WebElement element)
Example:
TableElement table = e.wrap(TableElement.class, driver.findElement(By.id("my-table")));
assertEquals("Foo", table.getHeaderCell(1).getText());
T - The wrapper element type.elementType - The type (class) containing the API to decorate with. Must
extend
AbstractElement.element - The element instance to decorateprotected Object executeScript(String script, Object... args)
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...)protected <T> T waitUntil(org.openqa.selenium.support.ui.ExpectedCondition<T> condition,
java.time.Duration duration)
NotFoundExceptions are ignored by default.
Use e.g. as
waitUntil(ExpectedConditions.presenceOfElementLocated(by), Duration.ofSeconds(10));
T - The condition return type.condition - Models a condition that might reasonably be expected to
eventually evaluate to something that is neither null nor
false.duration - The timeout duration for the wait.org.openqa.selenium.TimeoutException - If the timeout expires.FluentWait.until(java.util.function.Function<? super T, V>),
ExpectedCondition@Deprecated protected <T> T waitUntil(org.openqa.selenium.support.ui.ExpectedCondition<T> condition, long timeoutInSeconds)
waitUntil(ExpectedCondition, Duration) insteadNotFoundExceptions are ignored by
default.
This is a compatibility method that converts the timeouts given as seconds (Selenium 3 style) into timeouts given as Durations (Selenium 4 style).
Use e.g. as
waitUntil(ExpectedConditions.presenceOfElementLocated(by), 10);
T - The condition return type.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));
T - The condition return type.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>),
ExpectedConditionCopyright © 2012-2025 Vaadin Ltd. All Rights Reserved.