文档帮助

术语、图标和标签

许多类在使用配置对象创建(实例化)类时都有快捷名称。快捷名称被称为 alias(如果类扩展了 Ext.Component,则称为 xtype)。别名/xtype 列在适用类的类名旁边,以供快速参考。

访问级别

框架类或其成员可以指定为 privateprotected。否则,类/成员是 publicPublicprotectedprivate 是访问描述符,用于传达类或类成员应如何以及何时使用。

成员类型

成员语法

下面是一个示例类成员,我们可以对其进行剖析,以显示类成员的语法(在本例中为从 Ext.button.Button 类查看的 lookupComponent 方法)。

lookupComponent ( item ) : Ext.Component
受保护的

当原始配置对象在 items 配置初始化期间添加到此容器,或者当新项目 添加),或 {@link #insert 插入 时调用。

此方法将传递的对象转换为实例化的子组件。

当需要对子创建应用特殊处理时,可以在子类中覆盖此方法。

参数

item :  Object

正在添加的配置对象。

返回值
Ext.Component

要添加的组件。

让我们看一下成员行的每个部分

成员标志

API 文档使用许多标志来进一步传达类成员的功能和意图。标签可以由文本标签、缩写或图标表示。

类图标

- 表示框架类

- 单例框架类。*有关更多信息,请参阅单例标志

- 组件类型框架类(Ext JS 框架中扩展 Ext.Component 的任何类)

- 表示类、成员或指南在当前查看的版本中是新的

成员图标

- 表示类型为 config 的类成员

- 表示类型为 property 的类成员

- 表示类型为 method 的类成员

- 表示类型为 event 的类成员

- 表示类型为 theme variable 的类成员

- 表示类型为 theme mixin 的类成员

- 表示类、成员或指南在当前查看的版本中是新的

类成员快速导航菜单

在 API 文档页面上的类名正下方是一行按钮,对应于当前类拥有的成员类型。每个按钮显示按类型划分的成员计数(此计数会随着过滤器的应用而更新)。单击按钮将导航到该成员部分。将鼠标悬停在成员类型按钮上将显示该类型的所有成员的弹出菜单,以进行快速导航。

Getter 和 Setter 方法

Getter 和 setter 方法与类配置选项相关联,将显示在方法部分以及 API 文档和成员类型菜单的配置部分中,就在它们所作用的配置下方。getter 和 setter 方法文档将在配置行中找到,以便于参考。

历史记录栏

您的页面历史记录保存在 localstorage 中,并显示在顶部标题栏正下方(使用可用的实际空间)。默认情况下,仅显示的搜索结果是与您当前查看的产品/版本匹配的页面。您可以通过单击历史记录栏右侧的 按钮并选择“全部”单选按钮来展开显示的内容。这将显示所有产品/版本在历史记录栏中的所有最近页面。

在历史记录配置菜单中,您还将看到最近访问的页面列表。结果按“当前产品/版本”和“全部”单选按钮进行过滤。单击 按钮将清除历史记录栏以及保存在本地存储中的历史记录。

如果在历史记录配置菜单中选择了“全部”,“在历史记录栏中显示产品详情”的复选框选项将被启用。选中后,每个历史页面的产品/版本将与历史记录栏中的页面名称一起显示。将光标悬停在历史记录栏中的页面名称上也会显示产品/版本作为工具提示。

搜索和过滤器

可以使用页面顶部的搜索字段搜索 API 文档和指南。

在 API 文档页面上,还有一个过滤器输入字段,用于使用过滤器字符串过滤成员行。除了按字符串过滤外,您还可以按访问级别、继承和只读来过滤类成员。这是通过使用页面顶部的复选框来完成的。

API 类导航树底部的复选框过滤类列表以包括或排除私有类。

单击空搜索字段将显示您最近 10 次搜索,以便快速导航。

API 文档类元数据

每个 API 文档页面(Javascript 原始类型页面除外)都有一个与该类相关的元数据菜单视图。此元数据视图将具有以下一项或多项

展开和折叠示例和类成员

可运行的示例 (Fiddles) 默认在页面上展开。您可以使用代码块左上角的箭头单独折叠和展开示例代码块。您还可以使用页面右上角的切换按钮切换所有示例的折叠状态。全部切换状态将在页面加载之间记住。

类成员默认在页面上折叠。您可以使用成员行左侧的箭头图标或右上角的展开/折叠全部切换按钮全局展开和折叠成员。

桌面 -vs- 移动视图

在较窄的屏幕或浏览器上查看文档将导致针对较小尺寸优化的视图。桌面和“移动”视图之间的主要区别在于

查看类源代码

可以通过单击 API 文档页面顶部的类名来查看类源代码。可以通过单击成员行右侧的“查看源代码”链接来查看类成员的源代码。

GXT 4.x


顶部

示例

关于如何使用 GWT 和 GXT 驱动程序的杂项示例。

示例 1

@Test
public void testContainerScrollCausesNoHeightGrowth() {
  gotoEntryPoint(TestAccordionLayoutContainer.class);

  // Given we have ALC with tree inside panel
  WebElement alcElement = driver.findElement(new FasterByChained(By.xpath(".//*"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.container.AccordionLayoutContainer.class)));
  WebElement contentPanelElement = alcElement.findElement(new FasterByChained(By.xpath(".//*"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.ContentPanel.class)));

  // When we get the original size of the content panel with tree
  Dimension originalSize = contentPanelElement.getSize();

  // And we mouse over the tree elements
  for (int i = 0; i < NUMBER_OF_MOVEMENTS; i++) {
    new Actions(driver).moveToElement(contentPanelElement).moveByOffset(0, SPACING * i).click().build().perform();
    Dimension newSize = contentPanelElement.getSize();
    // Then the content panel should be the same size while mousing over
    Assert.assertEquals(originalSize, newSize);
  }

  for (int i = NUMBER_OF_MOVEMENTS; i > 0; i--) {
    new Actions(driver).moveToElement(contentPanelElement).moveByOffset(0, SPACING * i).click().build().perform();
    Dimension newSize = contentPanelElement.getSize();
    // Then the content panel should be the same size while mousing over
    Assert.assertEquals(originalSize, newSize);
  }

示例 2

@Test
public void testCheckBoxCellAlignment() throws InterruptedException {
  gotoEntryPoint(CheckBoxCellTest.class);

  // Given a list view a list of checkboxes with labels
  WebElement listViewElement = driver.findElement(new FasterByChained(By.xpath(".//*"), 
      new ByWidget(driver, ListView.class)));

  // When the label locations are retrieved from each item in the vertical row of checkboxes
  List<WebElement> elements = listViewElement.findElements(By.xpath(".//div/div/label"));
  Point cb1 = elements.get(0).getLocation();
  Point cb2 = elements.get(1).getLocation();
  Point cb3 = elements.get(2).getLocation();
  Point cb4 = elements.get(3).getLocation();

  // Then the labels will be in a straight line
  Assert.assertEquals(cb1.getX(), cb2.getX());
  Assert.assertEquals(cb1.getX(), cb3.getX());
  Assert.assertEquals(cb1.getX(), cb4.getX());
}

示例 3

@Test
public void testDialogInnerContainerHeightFillsContainer() {
  gotoEntryPoint(TestDialog.class);

  // Given a button opens a window
  Button button = GwtWidget.find(Button.class, driver).withText("Show Dialog").done();
  button.click();

  // When that window is visible
  Window window = getWindow();

  // And get the HTML element size
  Dimension sizeOnFistTime = getHtmlElement(window).getSize();

  // And close the window
  Button closeButton = GwtWidget.find(Button.class, driver).withText("Close").withElement(window.getElement()).done();
  closeButton.click();

  // And open the window back up
  button.click();

  // Then the HTML element will be the same size as the first time
  Dimension sizeOnSecondTime = getHtmlElement(getWindow()).getSize();
  Assert.assertEquals(sizeOnFistTime, sizeOnSecondTime);
}

public WebElement getHtmlElement(Window window) {
  WebElement htmlElement = window.getElement().findElement(
      new FasterByChained(By.xpath(".//*"), new ByWidget(driver, HTML.class)));
  return htmlElement;
}

public Window getWindow() {
  Window window = GwtWidget.find(Window.class, driver).withHeading("").done();
  return window;
}

示例 4

@Test
public void testHorizontalScroll() throws InterruptedException {
  gotoEntryPoint(FxScrollTest.class);

  // Given a div that can scroll
  WebElement outerScrollContainerElement = driver.findElement(new FasterByChained(By.xpath(".//*"), new ByWidget(
      driver, com.sencha.gxt.widget.core.client.container.FlowLayoutContainer.class)));
  WebElement innerScrollContainerElement = outerScrollContainerElement.findElement(new FasterByChained(
      By.xpath(".//*"), new ByWidget(driver, com.sencha.gxt.widget.core.client.container.FlowLayoutContainer.class)));

  // And the the div has not scrolled yet
  long scrollTop = (Long) ((JavascriptExecutor) driver).executeScript("return arguments[0].scrollTop;",
      innerScrollContainerElement);
  long scrollLeft = (Long) ((JavascriptExecutor) driver).executeScript("return arguments[0].scrollLeft;",
      innerScrollContainerElement);
  Assert.assertEquals(0, scrollTop);
  Assert.assertEquals(0, scrollLeft);

  // When the Scroll Horizontal is clicked
  Button button = GwtWidget.find(Button.class, driver).withText("Scroll Horizontal").done();
  button.click();

  // And scroll element scrolls to the right
  Thread.sleep(500);

  // Then the element scrolls 75px to Right
  scrollTop = (Long) ((JavascriptExecutor) driver).executeScript("return arguments[0].scrollTop;",
      innerScrollContainerElement);
  scrollLeft = (Long) ((JavascriptExecutor) driver).executeScript("return arguments[0].scrollLeft;",
      innerScrollContainerElement);
  Assert.assertEquals(0L, scrollTop);
  Assert.assertEquals(75L, scrollLeft);

  // When the Scroll Horizontal is clicked again
  button = GwtWidget.find(Button.class, driver).withText("Scroll Horizontal").done();
  button.click();

  // And scroll element scrolls back to it's home 0px
  Thread.sleep(500);

  // Then the element scrolls to 0px
  scrollTop = (Long) ((JavascriptExecutor) driver).executeScript("return arguments[0].scrollTop;",
      innerScrollContainerElement);
  scrollLeft = (Long) ((JavascriptExecutor) driver).executeScript("return arguments[0].scrollLeft;",
      innerScrollContainerElement);
  Assert.assertEquals(0L, scrollTop);
  Assert.assertEquals(0L, scrollLeft);
}

示例 5

@Test
public void testFirstVlcMarginTest() {
  gotoEntryPoint(LayoutVlcWithMargins.class);

  // Given there are 3 Vertical panels on the sample
  List<WebElement> vlcElements = driver.findElements(new FasterByChained(By.xpath(".//*"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.class)));

  // And get the first vlc container to work with
  WebElement vlcElement = vlcElements.get(0);

  // And get the simple containers inside the vlc containers
  List<WebElement> simplecontainers = vlcElement.findElements(new FasterByChained(By.xpath(".//*"), new ByWidget(driver,
      SimpleContainer.class)));

  // When measuring the first outer simple container
  WebElement sc0 = simplecontainers.get(0);
  Point locaiton0 = sc0.getLocation();
  Dimension size0 = sc0.getSize();
  // Then the first outer simple container is
  Assert.assertEquals(1, locaiton0.getY());
  Assert.assertEquals(50, size0.getHeight());

  // When measuring the first inner simple container
  WebElement sc1 = simplecontainers.get(1);
  Point locaiton1 = sc1.getLocation();
  Dimension size1 = sc1.getSize();
  // Then the first inner simple container is
  Assert.assertEquals(11, locaiton1.getY());
  Assert.assertEquals(30, size1.getHeight());

  // When measuring the second simple container in the stack
  WebElement sc2 = simplecontainers.get(2);
  Point locaiton2 = sc2.getLocation();
  Dimension size2 = sc2.getSize();
  // Then the second simple container in the stack is
  Assert.assertEquals(51, locaiton2.getY());
  Assert.assertEquals(148, size2.getHeight());
}

示例 6

private void selectItemTestMenu1(Integer index) {
  // Given focus is diverted to another element (TODO as a workaround, for focus behavior issue)
  Button button = GwtWidget.find(Button.class, driver).withText("Test Menu 2").done();
  button.click(); // open menu
  button = GwtWidget.find(Button.class, driver).withText("Test Menu 2").done();
  button.click(); // close menu (end workaround)

  // When I click on the button it opens up the menu
  button = GwtWidget.find(Button.class, driver).withText("Test Menu 1").done();
  button.click();

  // And when the first item is selected
  Menu menu = GwtWidget.find(Menu.class, driver).atDepth(0).done();
  menu.click("item " + index.toString());

  // And when the menu is reopened
  button = GwtWidget.find(Button.class, driver).withText("Test Menu 1").done();
  button.click();

  // And get the menu items
  menu = GwtWidget.find(Menu.class, driver).atDepth(0).done();
  List<WebElement> itemElements = menu.getElement().findElements(By.xpath(".//*//div/span"));

  // Then the first item is selected
  if (index == 1) {
    Assert.assertTrue(isItemSelected(itemElements.get(0)));
    Assert.assertFalse(isItemSelected(itemElements.get(1)));
    Assert.assertFalse(isItemSelected(itemElements.get(2)));
  } else if (index == 2) {
    Assert.assertFalse(isItemSelected(itemElements.get(0)));
    Assert.assertTrue(isItemSelected(itemElements.get(1)));
    Assert.assertFalse(isItemSelected(itemElements.get(2)));
  } else if (index == 3) {
    Assert.assertFalse(isItemSelected(itemElements.get(0)));
    Assert.assertFalse(isItemSelected(itemElements.get(1)));
    Assert.assertTrue(isItemSelected(itemElements.get(2)));
  }
}

示例 7

在列表中查找项目。

private void given() {
  // Given a content panel
  WebElement contentPanelElement = driver.findElement(new FasterByChained(By.xpath(".//div"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.ContentPanel.class)));

  // And it has two lists to select from
  List<WebElement> listElements = contentPanelElement.findElements(new ByChained(By.xpath(".//div"), new ByWidget(
      driver, com.sencha.gxt.widget.core.client.ListView.class)));
  list1 = new ListView(driver, listElements.get(0));
  list2 = new ListView(driver, listElements.get(1));

  // And there are two size html status elements, containing the size counts of the lists
  htmlSizeElements = contentPanelElement.findElements(new ByChained(By.xpath(".//*[contains(text(), 'size')]"),
      new ByWidget(driver, HTML.class)));
  size1Before = TestUtils.getIntFromText(htmlSizeElements.get(0));
  size2Before = TestUtils.getIntFromText(htmlSizeElements.get(1));

  // And the list1 list1Items are retrieved
  list1Items = list1.getElement().findElements(By.xpath(".//*[contains(text(), *)]"));

  // And what is the default item css classes, used to compare selected
  defaultCssClass = list1Items.get(0).getAttribute("class");
}

示例 8

在树中查找节点。

private void given() {
  // Given a content panel
  WebElement contentPanelElement = driver.findElement(new FasterByChained(By.xpath(".//div"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.ContentPanel.class)));

  // And it has two lists to select from
  List<WebElement> treeElements = contentPanelElement.findElements(new ByChained(By.xpath(".//div"), new ByWidget(
      driver, com.sencha.gxt.widget.core.client.tree.Tree.class)));
  tree1 = new Tree(driver, treeElements.get(0));
  tree2 = new Tree(driver, treeElements.get(1));

  // And there are two size html status elements, containing the size counts of the list
  htmlSizeElements = driver.findElements(new ByChained(By.xpath(".//*//div[1][contains(text(), 'size')]"),
      new ByWidget(driver, HTML.class)));
  size1Before = TestUtils.getIntFromText(htmlSizeElements.get(0));
  size2Before = TestUtils.getIntFromText(htmlSizeElements.get(1));

  // And get the root children
  rootchildren = tree1.getRootChildren();

  // And what is the default item css classes, used to compare selected
  defaultCssClass = rootchildren.get(0).getElement().getAttribute("class");
}

示例 9

private void given() {
  // Given a content panel
  WebElement contentPanelElement = driver.findElement(new FasterByChained(By.xpath(".//div"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.ContentPanel.class)));

  // And it has two lists to select from
  List<WebElement> treeElements = contentPanelElement.findElements(new ByChained(By.xpath(".//div"), new ByWidget(
      driver, com.sencha.gxt.widget.core.client.tree.Tree.class)));
  tree1 = new Tree(driver, treeElements.get(0));
  tree2 = new Tree(driver, treeElements.get(1));

  // And there are two size html status elements, containing the size counts of the list
  htmlSizeElements = driver.findElements(new ByChained(By.xpath(".//*//div[1][contains(text(), 'size')]"),
      new ByWidget(driver, HTML.class)));
  size1Before = TestUtils.getIntFromText(htmlSizeElements.get(0));
  size2Before = TestUtils.getIntFromText(htmlSizeElements.get(1));

  // And get the root children
  rootchildren = tree1.getRootChildren();

  // And what is the default item css classes, used to compare selected
  defaultCssClass = rootchildren.get(0).getElement().getAttribute("class");
}

示例 10

private void given() {
  // Given a content panel
  WebElement contentPanelElement = driver.findElement(new FasterByChained(By.xpath(".//div"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.ContentPanel.class)));

  // And it has two lists to select from
  List<WebElement> treeElements = contentPanelElement.findElements(new ByChained(By.xpath(".//div"), new ByWidget(
      driver, com.sencha.gxt.widget.core.client.tree.Tree.class)));
  tree1 = new Tree(driver, treeElements.get(0));
  tree2 = new Tree(driver, treeElements.get(1));

  // And there are two size html status elements, containing the size counts of the list
  htmlSizeElements = driver.findElements(new ByChained(By.xpath(".//*//div[1][contains(text(), 'size')]"),
      new ByWidget(driver, HTML.class)));
  size1Before = TestUtils.getIntFromText(htmlSizeElements.get(0));
  size2Before = TestUtils.getIntFromText(htmlSizeElements.get(1));

  // And get the root children
  rootchildren = tree1.getRootChildren();

  // And what is the default item css classes, used to compare selected
  defaultCssClass = rootchildren.get(0).getElement().getAttribute("class");
}

示例 11

public void testTreeExpandingOnlyExpandsOneNode() throws InterruptedException {
  gotoEntryPoint(TreeExpanding.class);

  // Given we have a tree that has two nodes to expand
  WebElement treeElement = driver.findElement(new ByChained(By.xpath(".//*"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.tree.Tree.class)));
  Tree tree = new Tree(driver, treeElement);

  // When get the root children
  List<Item> rootChildren = tree.getRootChildren();

  // And the first node and its children are expanded
  rootChildren.get(0).toggleExpand();
  rootChildren.get(0).getChildren().get(0).toggleExpand();

  // And the first node is then collapsed
  rootChildren.get(0).toggleExpand();

  // And the second node and children are expanded
  rootChildren.get(1).toggleExpand();
  rootChildren.get(1).getChildren().get(0).toggleExpand();

  // Then only the second node should be expanded
  Assert.assertFalse(rootChildren.get(0).isExpanded());
}

示例 12

@Test
public void testClickingOnCheckBoxWhenEnabled() throws InterruptedException {
  gotoEntryPoint(TreeWithCheckboxes.class);

  // Given we have a tree with checkboxes
  WebElement treeElement = driver.findElement(new ByChained(By.xpath(".//*"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.tree.Tree.class)));
  Tree tree = new Tree(driver, treeElement);

  // When root has children
  List<Item> rootChildren = tree.getRootChildren();

  // And when the checkbox is checked
  rootChildren.get(0).toggleCheck();

  // Then the checkbox is checked
  Assert.assertTrue(rootChildren.get(0).isChecked());
}

示例 13

@Test
public void testTreeNodesHighlight() throws InterruptedException {
  gotoEntryPoint(TreeWithScroll.class);

  // Given a toolbar is collapsed with clickable image to expand menu
  WebElement toolBarWithImageElement = driver.findElement(By.tagName("img"));

  // And the toolbar expands, and Expand All tree nodes is clicked
  new Actions(driver).moveToElement(toolBarWithImageElement).click().moveByOffset(0, 27).clickAndHold().release().build().perform();

  // And wait for tree to expand
  Thread.sleep(700);//TODO replace with waitfor command, this timeout is too long and saucelabs is giving up? intermittent.

  // When the size of the tree is larger than the container
  WebElement treeElement = driver.findElement(new FasterByChained(By.xpath(".//*"), new ByWidget(driver,
      com.sencha.gxt.widget.core.client.tree.Tree.class)));

  // And get the tree scroll size
  Long treeScrollWidth = (Long) ((JavascriptExecutor) driver).executeScript("return arguments[0].scrollWidth;",
      treeElement);

  // And clicking on first leaf causes a selection highlight
  List<WebElement> treeLeafElements = treeElement.findElements(By.xpath(".//div/div/span[3]"));
  WebElement firstLeafElement = treeLeafElements.get(0);
  firstLeafElement.click();

  // Then measure the selection highlight
  WebElement firstLeafParentElement = firstLeafElement.findElement(By.xpath(".."));
  Dimension firstLeafSize = firstLeafParentElement.getSize();

  // And assert that the container scroll size is the same as the highlighted size
  Assert.assertEquals(treeScrollWidth.intValue(), firstLeafSize.getWidth());
}

示例 14

@Test
public void testWindowMaximizedWidthTest() throws InterruptedException {
  gotoEntryPoint(WindowRestoreTest.class);

  // Given a button opens a window
  Button openWindowButton = GwtWidget.find(Button.class, driver).withText("Open Window").done();

  // When the window is opened by click on button
  openWindowButton.click();

  // And maximize window
  setBrowserWindowMaximized();

  // And wait for window width fullsize
  final Matches sizeMatches = new Matches();
  WebDriverWait wait = new WebDriverWait(driver, 10);
  wait.until(new ExpectedCondition<Boolean>() {
    public Boolean apply(WebDriver driver) {
      boolean result = getWindow().getElement().getSize().getWidth() == getBrowserWindowSize().getWidth();
      sizeMatches.matches = result;
      return result;
    }
  });

  // Then the window will be the size of the maximized size
  Assert.assertTrue(sizeMatches.matches);
}

public class Matches {
  public boolean matches;
}

private Window getWindow() {
  return GwtWidget.find(Window.class, driver).atTop().done();
}

private List<WebElement> getButtonElements() {
  List<WebElement> toolbuttonElements = getWindow().getElement().findElements(
      new FasterByChained(By.xpath(".//*"), new ByWidget(driver, ToolButton.class)));
  return toolbuttonElements;
}

示例 15

@Test
public void testComboboxEscapePressDoesntHideWindow() throws InterruptedException {
  gotoEntryPoint(TestWindowWithComboBox.class);

  // Given we have a open window
  Button button = GwtWidget.find(Button.class, driver).withText("Open Window").done();
  button.click();

  // When that window is visible
  Window window = GwtWidget.find(Window.class, driver).atTop().done();

  // And find the combobox
  WebElement comboBoxElement = window.getElement().findElement(
      new FasterByChained(By.xpath(".//*"), new ByWidget(driver, com.sencha.gxt.widget.core.client.form.ComboBox.class)));
  WebElement comboInputElement = comboBoxElement.findElement(By.tagName("input")); 

  // And focus and press the letter 'a' so it expands
  comboInputElement.click();
  comboInputElement.sendKeys("a");

  // And wait for Combobox to expand
  Thread.sleep(1000);

  // Then press escape, should not close window
  comboInputElement.sendKeys(Keys.ESCAPE.toString());

  // And the window is open and visible
  Assert.assertTrue(window.getElement().isDisplayed());
}

GXT 4.x