コード例 #1
0
  public void analyzeLinks() {
    int linksCount = selenium.getXpathCount("//a").intValue();

    ArrayList<String> linksWithText = new ArrayList<String>();
    ArrayList<String> linksWithNoText = new ArrayList<String>();

    for (int i = 1; i <= linksCount; i++) {

      if (!selenium.getText("xpath=(//a)[" + i + "]").equals("")) {
        linksWithText.add(selenium.getText("xpath=(//a)[" + i + "]"));
      } else {
        linksWithNoText.add(selenium.getAttribute("xpath=(//a)[" + i + "]@href"));
      }
    }

    java.util.Iterator<String> iterator = linksWithText.iterator();

    int i = 0;
    while (iterator.hasNext()) {
      i = i + 1;
      logger.info("Link " + i + " " + iterator.next().toString());
    }

    iterator = linksWithNoText.iterator();

    i = 0;
    while (iterator.hasNext()) {
      i = i + 1;
      logger.info("Link " + i + " with no Text so logging href " + iterator.next().toString());
    }
  }
コード例 #2
0
 public boolean waitForTextNotPresent(String locator, String textToCheck) {
   for (int second = 0; ; second++) {
     if (second >= TestConsts.TIMEOUT) return false;
     try {
       if (!textToCheck.equals(selenium.getText(locator))) return true;
     } catch (Exception e) {
     }
     sleep(1000);
   }
 }