@GwtWidget.ForWidget(value=com.google.gwt.user.client.ui.Widget.class) public class GwtWidget<F extends GwtWidgetFinder<?>> extends Object
GwtWidgetFinder
type. This should have a no-arg,
public constructor so it can be automatically created, and should follow the basic builder pattern to
enable finding that type of widget in predictable ways.
The find
methods in this class are used to find some widget using that widget's finder type.
A GwtWidget subclass may be annotated with @ForWidget
to indicate a specific widget
type that it represents. This is used as a check, to make sure that the dom element the GwtWidget wraps
is connected to the right type of Widget.
The is(Class)
and as(Class)
methods are modeled after GWT's Element classes, and their
checks that any given JavaScriptObject is indeed of the type expected, as a JavaScriptObject can be of
any of any type and cast arbitrarily. In the same way, a GwtWidget might be mapped onto any element or
widget, even if it doesn't map. The is(Class)
method allows a test to verify that it is of the
type specified, and the as(Class)
method creates an object of the specified type by wrapping
the current element and driver in the new type. This is usually not required when working with a
GwtWidgetFinder
and the find
methods, as those typically only return elements that already
match the widget.Modifier and Type | Class and Description |
---|---|
static interface |
GwtWidget.ForWidget
Declares that the annotated type is a GwtWidget for a particular Widget subclass.
|
Constructor and Description |
---|
GwtWidget(WebDriver driver,
WebElement element)
Creates a new GwtWidget type.
|
Modifier and Type | Method and Description |
---|---|
<W extends GwtWidget<?>> |
as(Class<W> clazz)
Re-wraps the widget's element as some other kind of widget.
|
protected static String |
escapeToString(String str)
Helper method to generate a string literal that can be used in an xpath
|
<W extends GwtWidget<T>,T extends GwtWidgetFinder<W>> |
find(Class<W> widgetType)
Starting point to find a widget using the finder dsl - pass in the GwtWidget subclass and an instance
of its basic finder will be created, with the current element and driver to act as a starting point.
|
static <W extends GwtWidget<T>,T extends GwtWidgetFinder<W>> |
find(Class<W> widgetType,
WebDriver driver)
Static helper method to enable finding without an initial widget to start from.
|
static <W extends GwtWidget<T>,T extends GwtWidgetFinder<W>> |
find(Class<W> widgetType,
WebDriver driver,
WebElement element)
Static helper method to enable finding without an initial widget to work from.
|
WebDriver |
getDriver()
Gets the current webdriver instance used to interact with this widget.
|
WebElement |
getElement()
Gets the root WebElement being used as a GWT Widget
|
<W extends GwtWidget<?>> |
is(Class<W> clazz)
Checks if this widget is of the specified type and so can
|
public GwtWidget(WebDriver driver, WebElement element)
driver
- a webdriver instance to use when interacting with the widget or finding other widgetselement
- the element to wrap with a GwtDriver instancepublic WebElement getElement()
public WebDriver getDriver()
public <W extends GwtWidget<T>,T extends GwtWidgetFinder<W>> T find(Class<W> widgetType)
done()
call, which then tries to find the actual widget.widgetType
- the type of widget to start findingGwtWidgetFinder
public static <W extends GwtWidget<T>,T extends GwtWidgetFinder<W>> T find(Class<W> widgetType, WebDriver driver)
GwtWidgetFinder.withElement(WebElement)
will be invoked.widgetType
- driver
- the WebDriver instance to use when findingfind(Class)
,
find(Class, WebDriver, WebElement)
public static <W extends GwtWidget<T>,T extends GwtWidgetFinder<W>> T find(Class<W> widgetType, WebDriver driver, WebElement element)
widgetType
- the type of widget to start findingdriver
- the WebDriver instance to use when findingelement
- the element to start finding fromfind(Class)
public <W extends GwtWidget<?>> W as(Class<W> clazz)
clazz
- the type of widget to createIllegalArgumentException
- if the element is not of the specified typepublic <W extends GwtWidget<?>> boolean is(Class<W> clazz)
clazz
- the type of widget to test againstCopyright © 2012-2013 Sencha Labs. All Rights Reserved.