Ejemplo n.º 1
1
  /**
   * @param driver webdriver object to access the browser
   * @param term the search term expected in the results
   * @return is it true or not
   */
  public static Boolean isInSearchResults(WebDriver driver, String term, Integer pageCounter) {
    Boolean result = Boolean.FALSE;
    String xpath = "//tr[@class='csc-row']/td/a[text()='" + term + "']";
    String textTemplate;
    String currentPageIndicatorFieldText;

    if (!driver.findElements(By.xpath(xpath)).isEmpty()) {
      result = Boolean.TRUE;
    } else {
      try {
        driver.findElement(By.className("flc-pager-next")).click();
        new WebDriverWait(driver, 10)
            .until(
                ExpectedConditions.invisibilityOfElementLocated(
                    By.className("cs-loading-indicator")));

        pageCounter += 1;
        WebElement textField = driver.findElement(By.xpath("//*[@id=\"pager-bottom\"]/li[5]"));

        textTemplate = "Viewing page " + pageCounter + ".";
        currentPageIndicatorFieldText = textField.getText();

        if (!(currentPageIndicatorFieldText.contains(textTemplate))) {
          return Boolean
              .FALSE; // fixes infinite loop of button-clicking when the item is not found.
        }
        result = isInSearchResults(driver, term, pageCounter);
      } catch (Exception e) {
        log(e.getMessage());
      }
    }
    return result;
  }
Ejemplo n.º 2
0
  public static void verifyAllFieldsCleared(String recordType, WebDriver driver) {
    try {
      Record record = loadRecordOfType(recordType);
      verifyFieldsAreCleared(driver, record.getFieldMap());
      verifySelectFieldsCleared(driver, record.getSelectMap());

    } catch (Exception e) {
      log(e.getMessage());
    }
  }
Ejemplo n.º 3
0
  /** Clears all fields except required fields */
  public static void clearAllFieldsFor(String recordType, WebDriver driver) {
    try {
      Record record = loadRecordOfType(recordType);
      clearFields(driver, record.getFieldMap());
      clearSelectFields(driver, record.getSelectMap());
      clearVocabFields(driver, record.getVocabMap());
      // TODO ADD Dates and Checkboxes

    } catch (Exception e) {
      log(e.getMessage());
    }
  }