org.xwiki.test.ui.XWikiWebDriver类的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(62)

本文整理了Java中org.xwiki.test.ui.XWikiWebDriver类的一些代码示例,展示了XWikiWebDriver类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XWikiWebDriver类的具体详情如下:
包路径:org.xwiki.test.ui.XWikiWebDriver
类名称:XWikiWebDriver

XWikiWebDriver介绍

[英]Wraps a org.openqa.selenium.WebDriver instance and adds new APIs useful for XWiki tests.
[中]包装一个组织。openqa。硒。WebDriver实例,并添加了对XWiki测试有用的新API。

代码示例

代码示例来源:origin: org.xwiki.platform/xwiki-platform-flamingo-theme-test-pageobjects

public List<String> getVariableCategories()
{
  List<String> results = new ArrayList<>();
  List<WebElement> categoryElems = getDriver().findElements(
      By.xpath("//div[@id='panel-theme-variables']//div[@class='panel-body']"
          + "//li//a[@data-toggle='tab']"));
  for (WebElement elem : categoryElems) {
    results.add(elem.getText());
  }
  return results;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * @since 7.0RC1
 */
private void clickSubMenuEntryFromMenu(By menuBy, String id)
{
  // Open the parent Menu
  getDriver().findElement(menuBy).click();
  // Wait for the submenu entry to be visible
  getDriver().waitUntilElementIsVisible(By.id(id));
  // Click on the specified entry
  getDriver().findElement(By.id(id)).click();
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

public boolean hasElementWithoutWaiting(By by)
{
  try {
    findElementWithoutWaiting(by);
    return true;
  } catch (NoSuchElementException e) {
    return false;
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * Forces the driver to wait for a {@link #getTimeout()} number of seconds when looking up page elements
 * before declaring that it cannot find them.
 */
public void setDriverImplicitWait()
{
  setDriverImplicitWait(getTimeout());
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * Wait until the element given by the locator is displayed. Give up after specified timeout (in seconds).
 * <p>
 * Only use this API if you absolutely need a longer timeout than the default, otherwise use
 * {@link #waitUntilElementIsVisible(org.openqa.selenium.By)}.
 *
 * @param locator the locator for the element to look for
 * @param timeout the timeout after which to give up
 * @since 5.4RC1
 */
public void waitUntilElementIsVisible(final By locator, int timeout)
{
  int currentTimeout = getTimeout();
  try {
    setTimeout(timeout);
    waitUntilElementsAreVisible(new By[] {locator}, true);
  } finally {
    setTimeout(currentTimeout);
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

public List<WebElement> findElementsWithoutWaiting(By by)
{
  // Temporarily remove the implicit wait on the driver since we're doing our own waits...
  manage().timeouts().implicitlyWait(0, TimeUnit.SECONDS);
  try {
    return findElements(by);
  } finally {
    setDriverImplicitWait();
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

public void deleteProperty(String propertyName)
{
  final By propertyLocator = By.id("xproperty_" + propertyName);
  final WebElement propertyContainer = getDriver().findElement(propertyLocator);
  WebElement deleteLink = propertyContainer.findElement(By.className("delete"));
  deleteLink.click();
  // Expect a confirmation box
  getDriver().waitUntilElementIsVisible(By.className("xdialog-box-confirmation"));
  getDriver().findElement(By.cssSelector(".xdialog-box-confirmation input[value='Yes']")).click();
  getDriver().waitUntilElementDisappears(propertyLocator);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

public void removeAllDeprecatedProperties()
{
  getDriver().findElement(By.className("syncAllProperties")).click();
  getDriver().waitUntilElementDisappears(By.className("deprecatedProperties"));
}

代码示例来源:origin: phenotips/phenotips

public boolean checkImmunodeficiencyDissapearsFromRightInvestigateBox()
{
  this.getDriver().waitUntilElementDisappears(By
    .xpath(
      "//*[contains(@class, 'background-search')]//label[contains(@class, 'yes')][.//input[@value = 'HP:0002721']]"));
  try {
    return !getDriver()
      .hasElement(
        By.xpath(
          "//*[contains(@class, 'background-search')]//label[contains(@class, 'yes')][.//input[@value = 'HP:0002721']]"));
  } catch (NoSuchElementException e) {
    return false;
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * @return the list of properties that have been modified
 */
public List<String> getPropertyNames()
{
  List<String> propertyNames = new ArrayList<>();
  for (WebElement element : getDriver().findElementsWithoutWaiting(this.container, By.className("diff-header"))) {
    propertyNames.add(element.getText().trim());
  }
  return propertyNames;
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * @param paneId valid values: "history", "comments", etc
 */
public void waitForDocExtraPaneActive(String paneId)
{
  getDriver().waitUntilElementIsVisible(By.id(paneId + "content"));
}

代码示例来源:origin: org.phenotips/patient-data-pageobjects

@Override
  public void waitUntilPageJSIsLoaded()
  {
    getDriver().waitUntilJavascriptCondition("return window.Prototype != null && window.Prototype.Version != null");
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

public AttachmentsPane openAttachmentsDocExtraPane()
{
  getDriver().findElement(By.id("Attachmentslink")).click();
  waitForDocExtraPaneActive("attachments");
  return new AttachmentsPane();
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * @return the number of rows in the live table
 */
public int getRowCount()
{
  WebElement liveTableBody = getDriver().findElementWithoutWaiting(By.id(this.livetableId + "-display"));
  // We use XPath because we're interested only in the direct children.
  return getDriver().findElementsWithoutWaiting(liveTableBody, By.xpath("tr")).size();
}

代码示例来源:origin: phenotips/phenotips

public boolean hasPhenotypeSelected(String label, boolean positive)
{
  return getDriver().hasElement(
    By.xpath("//*[contains(@class, 'phenotype-info')]//*[contains(text(),'" + (positive ? "" : "NO ") + label
      + "')]"));
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * Waits until the given locator corresponds to either a hidden or a deleted element.
 *
 * @param locator the locator to wait for
 */
public void waitUntilElementDisappears(final By locator)
{
  waitUntilElementDisappears(null, locator);
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * @return true if we are currently logged in, false otherwise
 */
public boolean isAuthenticated()
{
  return getDriver().hasElementWithoutWaiting(By.id("tmUser"));
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-administration-test-pageobjects

private void setAuthenticatedView(boolean enabled)
{
  String desiredAltValue = enabled ? "yes" : "no";
  if (!this.forceAuthenticatedViewLink.getAttribute("alt").equals(desiredAltValue)) {
    this.forceAuthenticatedViewLink.click();
    // Wait for the setting to apply. Wait longer than usual in this case in an attempt to avoid some false
    // positives in the tests.
    int defaultTimeout = getDriver().getTimeout();
    try {
      getDriver().setTimeout(defaultTimeout * 2);
      getDriver().waitUntilElementHasAttributeValue(
        By.id(this.forceAuthenticatedViewLink.getAttribute("id")), "alt", desiredAltValue);
    } finally {
      // Restore the utils timeout for other tests.
      getDriver().setTimeout(defaultTimeout);
    }
  }
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

public HistoryPane deleteRangeVersions(String fromVersion, String toVersion)
{
  getDriver().makeConfirmDialogSilent(true);
  this.selectVersions(fromVersion, toVersion);
  getDriver().findElementWithoutWaiting(pane, By.xpath(".//input[@name = 'deleteVersions']")).click();
  return new HistoryPane();
}

代码示例来源:origin: org.xwiki.platform/xwiki-platform-test-ui

/**
 * Same as {@link #waitUntilRowCountGreaterThan(int, int)} but with a specific timeout (ie not using the default
 * timeout)
 *
 * @since 9.1RC1
 */
// We need to decide if it's bettter to introduce this method or to globally increase the default timeout.
public void waitUntilRowCountGreaterThan(int minimalExpectedRowCount, int timeout)
{
  int originalTimeout = getDriver().getTimeout();
  getDriver().setTimeout(timeout);
  try {
    waitUntilRowCountGreaterThan(minimalExpectedRowCount);
  } finally {
    getDriver().setTimeout(originalTimeout);
  }
}

相关文章