Docs Help

Terms, Icons, and Labels

Many classes have shortcut names used when creating (instantiating) a class with a configuration object. The shortcut name is referred to as an alias (or xtype if the class extends Ext.Component). The alias/xtype is listed next to the class name of applicable classes for quick reference.

Access Levels

Framework classes or their members may be specified as private or protected. Else, the class / member is public. Public, protected, and private are access descriptors used to convey how and when the class or class member should be used.

Member Types

Member Syntax

Below is an example class member that we can disect to show the syntax of a class member (the lookupComponent method as viewed from the Ext.button.Button class in this case).

lookupComponent ( item ) : Ext.Component
protected

Called when a raw config object is added to this container either during initialization of the items config, or when new items are added), or {@link #insert inserted.

This method converts the passed object into an instanced child component.

This may be overridden in subclasses when special processing needs to be applied to child creation.

Parameters

item :  Object

The config object being added.

Returns
Ext.Component

The component to be added.

Let's look at each part of the member row:

Member Flags

The API documentation uses a number of flags to further commnicate the class member's function and intent. The label may be represented by a text label, an abbreviation, or an icon.

Class Icons

- Indicates a framework class

- A singleton framework class. *See the singleton flag for more information

- A component-type framework class (any class within the Ext JS framework that extends Ext.Component)

- Indicates that the class, member, or guide is new in the currently viewed version

Member Icons

- Indicates a class member of type config

- Indicates a class member of type property

- Indicates a class member of type method

- Indicates a class member of type event

- Indicates a class member of type theme variable

- Indicates a class member of type theme mixin

- Indicates that the class, member, or guide is new in the currently viewed version

Class Member Quick-Nav Menu

Just below the class name on an API doc page is a row of buttons corresponding to the types of members owned by the current class. Each button shows a count of members by type (this count is updated as filters are applied). Clicking the button will navigate you to that member section. Hovering over the member-type button will reveal a popup menu of all members of that type for quick navigation.

Getter and Setter Methods

Getting and setter methods that correlate to a class config option will show up in the methods section as well as in the configs section of both the API doc and the member-type menus just beneath the config they work with. The getter and setter method documentation will be found in the config row for easy reference.

History Bar

Your page history is kept in localstorage and displayed (using the available real estate) just below the top title bar. By default, the only search results shown are the pages matching the product / version you're currently viewing. You can expand what is displayed by clicking on the button on the right-hand side of the history bar and choosing the "All" radio option. This will show all recent pages in the history bar for all products / versions.

Within the history config menu you will also see a listing of your recent page visits. The results are filtered by the "Current Product / Version" and "All" radio options. Clicking on the button will clear the history bar as well as the history kept in local storage.

If "All" is selected in the history config menu the checkbox option for "Show product details in the history bar" will be enabled. When checked, the product/version for each historic page will show alongside the page name in the history bar. Hovering the cursor over the page names in the history bar will also show the product/version as a tooltip.

Search and Filters

Both API docs and guides can be searched for using the search field at the top of the page.

On API doc pages there is also a filter input field that filters the member rows using the filter string. In addition to filtering by string you can filter the class members by access level, inheritance, and read only. This is done using the checkboxes at the top of the page.

The checkbox at the bottom of the API class navigation tree filters the class list to include or exclude private classes.

Clicking on an empty search field will show your last 10 searches for quick navigation.

API Doc Class Metadata

Each API doc page (with the exception of Javascript primitives pages) has a menu view of metadata relating to that class. This metadata view will have one or more of the following:

Expanding and Collapsing Examples and Class Members

Runnable examples (Fiddles) are expanded on a page by default. You can collapse and expand example code blocks individually using the arrow on the top-left of the code block. You can also toggle the collapse state of all examples using the toggle button on the top-right of the page. The toggle-all state will be remembered between page loads.

Class members are collapsed on a page by default. You can expand and collapse members using the arrow icon on the left of the member row or globally using the expand / collapse all toggle button top-right.

Desktop -vs- Mobile View

Viewing the docs on narrower screens or browsers will result in a view optimized for a smaller form factor. The primary differences between the desktop and "mobile" view are:

Viewing the Class Source

The class source can be viewed by clicking on the class name at the top of an API doc page. The source for class members can be viewed by clicking on the "view source" link on the right-hand side of the member row.

GXT 4.x


top

This guide covers building GWT WebDriver widget binding Models.

Reference

Model Parts

ForWidget

The GWT Driver model class annotation @ForWidget(Label.class) or @ForWidget(com.google.gwt.user.client.ui.Label.class) which is not required but is handy for casting the reference using .is or .as.

@ForWidget(Label.class)
public class GwtLabel extends GwtWidget<GwtLabelFinder> {
  //...
}

GwtWidgetFinder

GwtWidgetFinder<Model> uses the builder pattern to instantiate the model and its goal is to give the finder directions to the widget in the DOM.

@ForWidget(Label.class)
public class GwtLabel extends GwtWidget<GwtLabelFinder> {
  public GwtLabel(WebDriver driver, WebElement element) {
    super(driver, element);
  }

  // This is the definition to how the widget is found, each super model will have this. 
  public static class GwtLabelFinder extends GwtWidgetFinder<GwtLabel> {
    @Override
    public GwtLabel done() {
      //...
      return new GwtLabel(driver, webElement);
    }
  }
}

Widget Method Accessors

Accessing the translated javascript functions can be done by using the ClientMethodsFactory. The ClientMethodsFactory interface creates a proxy to interface with the translated javascript in the application.

@ForWidget(com.sencha.gxt.widget.core.client.tree.Tree.class)
public class Tree extends GwtWidget<GwtWidgetFinder<Tree>> {
  public interface TreeMethods extends ClientMethods {

    // this will tap the Tree.class isExpand method using reflection
    boolean isExpanded(WebElement widget, WebElement item);

    //...
  }

  private final TreeMethods methods;

  public Tree(WebDriver driver, WebElement element) {
    super(driver, element);
    methods = ClientMethodsFactory.create(TreeMethods.class, driver);
  }

  public class Item {
    public boolean isExpanded() {
      // this accesses the reflected method
      return methods.isExpanded(getWidgetElement(), getElement());
    }

    //...
  }

  //...
}

Extending

Extending a GWT Driver model. It's important to note that when using this method, the GwtWidget.find uses the super class name and then is cast to the subclass name.

  • Example of the extension.

    @ForWidget(com.sencha.gxt.widget.core.client.form.ComboBox.class)
    public class ComboBox extends Field {
    //...
    }
    
  • Example of instantiating it's use. Notice that the find(Field.class,...) uses the model's super class name and .as(ComboBox.class) casts it to the models subclass name.

    ComboBox combo = GwtWidget.find(Field.class, driver).withText("Pick").done().as(ComboBox.class);
    

Examples

Basic Example

This example is for the GWT Label widget. Source

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.senchalabs.gwt.gwtdriver.by.ByNearestWidget;
import org.senchalabs.gwt.gwtdriver.by.FasterByChained;
import org.senchalabs.gwt.gwtdriver.models.GwtLabel.GwtLabelFinder;
import org.senchalabs.gwt.gwtdriver.models.GwtWidget.ForWidget;

import com.google.gwt.user.client.ui.Label;

@ForWidget(Label.class)
public class GwtLabel extends GwtWidget<GwtLabelFinder> {
  public GwtLabel(WebDriver driver, WebElement element) {
    super(driver, element);
  }

  public String getText() {
    return getElement().getText();
  }

  public static class GwtLabelFinder extends GwtWidgetFinder<GwtLabel> {
    String text;

    public GwtLabelFinder withText(String text) {
      this.text = text;
      return this;
    }

    @Override
    public GwtLabel done() {
      WebElement elt = this.elt;
      if (text != null) {
        elt = elt.findElement(
          new FasterByChained(
            By.xpath(".//*[contains(text(), " + escapeToString(text) + ")]"),
              new ByNearestWidget(driver, Label.class)));
      }
      return new GwtLabel(driver, elt);
    }
  }
}

Widget Method Accessors Example

This is an example using widget function accessors to plugin to the translated javascript. Model Source

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import com.google.common.base.Predicate;
import org.openqa.selenium.By;
import org.openqa.selenium.NotFoundException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.FluentWait;
import org.senchalabs.gwt.gwtdriver.invoke.ClientMethods;
import org.senchalabs.gwt.gwtdriver.invoke.ClientMethodsFactory;
import org.senchalabs.gwt.gwtdriver.models.GwtWidget;
import org.senchalabs.gwt.gwtdriver.models.GwtWidget.ForWidget;
import org.senchalabs.gwt.gwtdriver.models.GwtWidgetFinder;

@ForWidget(com.sencha.gxt.widget.core.client.tree.Tree.class)
public class Tree extends GwtWidget<GwtWidgetFinder<Tree>> {
  public interface TreeMethods extends ClientMethods {
    /** From any element within the widget, finds the nearest complete node. */
    WebElement getNodeElement(WebElement widget, WebElement elt);

    /** Find the root children */
    List<WebElement> getRootChildren(WebElement widget);

    /** Find the children of the given item */
    List<WebElement> getChildren(WebElement widget, WebElement item);

    /** Gets the element of the parent node of the given item */
    WebElement getParent(WebElement widget, WebElement item);

    boolean isExpanded(WebElement widget, WebElement item);

    WebElement getExpandElement(WebElement widget, WebElement item);

    WebElement getCheckElement(WebElement widget, WebElement item);

    boolean isLoading(WebElement widget, WebElement item);
  }

  private final TreeMethods methods;

  public Tree(WebDriver driver, WebElement element) {
    super(driver, element);
    methods = ClientMethodsFactory.create(TreeMethods.class, driver);
  }

  public class Item {
    private final WebElement elt;

    private Item(WebElement element) {
      this.elt = element;
    }

    public String getText() {
      return elt.getText();
    }

    public WebElement getElement() {
      return elt;
    }

    public void toggleExpand() {
      methods.getExpandElement(getWidgetElement(), getElement()).click();
    }

    public boolean isExpanded() {
      return methods.isExpanded(getWidgetElement(), getElement());
    }

    public void toggleCheck() {
      methods.getCheckElement(getWidgetElement(), getElement()).click();
    }

    public void waitForLoaded() {
      waitForLoaded(10, TimeUnit.SECONDS);
    }

    public void waitForLoaded(long duration, TimeUnit unit) {
      new FluentWait<WebDriver>(getDriver()).withTimeout(duration, unit).ignoring(NotFoundException.class).until(
          new Predicate<WebDriver>() {
            @Override
            public boolean apply(WebDriver input) {
              return !methods.isLoading(getWidgetElement(), getElement());
            }
          });
    }

    public List<Item> getChildren() {
      List<WebElement> childNodes = methods.getChildren(getWidgetElement(), getElement());
      List<Item> items = new ArrayList<Item>();
      for (WebElement childNode : childNodes) {
        items.add(new Item(childNode));
      }
      return items;
    }

    public boolean isLeaf() {
      return getChildren().isEmpty();
    }

    public Item getParent() {
      return new Item(methods.getParent(getWidgetElement(), getElement()));
    }
  }

  public Item findItemWithText(String text) {
    String escaped = escapeToString(text);
    return new Item(methods.getNodeElement(getElement(),
        getElement().findElement(By.xpath(".//*[contains(text()," + escaped + ")]"))));
  }

  public List<Item> getRootChildren() {
    List<WebElement> childNodes = methods.getRootChildren(getWidgetElement());
    List<Item> items = new ArrayList<Item>();
    for (WebElement child : childNodes) {
      items.add(new Item(child));
    }
    return items;
  }

  protected WebElement getWidgetElement() {
    return getElement();
  }
}

GXT 4.x