Exemple #1
0
  // Sends the number of catapults to the GUI
  public static void setCatapult() {

    // loop through all the show unit lines
    // if the unit name is found then display it on the GUI
    for (int i = 1; i < 15; i++) {
      try {
        String catapultLabel =
            WebAutomation.driver
                .findElement(By.xpath("//*[@id=\"show_units\"]/div/table/tbody/tr[" + i + "]"))
                .getText();
        if (substring(catapultLabel, 2, 10).equals("Catapult")
            || substring(catapultLabel, 3, 11).equals("Catapult")
            || substring(catapultLabel, 4, 12).equals("Catapult")
            || substring(catapultLabel, 5, 13).equals("Catapult")
            || substring(catapultLabel, 6, 14).equals("Catapult")
            || substring(catapultLabel, 7, 15).equals("Catapult")) {
          TroopsDetailPanel.setCatapultLabel(
              WebAutomation.driver
                  .findElement(
                      By.xpath("//*[@id='show_units']/div/table/tbody/tr[" + i + "]/td/strong"))
                  .getText());
          break;
        }
        // the troop was not found
        else {
          TroopsDetailPanel.setCatapultLabel("0");
        }
      } catch (NoSuchElementException e) {
      }
    }
  }
Exemple #2
0
  // Sends whether or not the village has a paladin
  public static void setPaladin() {

    // loop through all the show unit lines
    // if the unit name is found then display it on the GUI
    for (int i = 1; i < 15; i++) {
      try {
        String paladinLabel =
            WebAutomation.driver
                .findElement(By.xpath("//*[@id=\"show_units\"]/div/table/tbody/tr[" + i + "]"))
                .getText();
        if (substring(paladinLabel, 0, 7).equals("Paladin")) {
          TroopsDetailPanel.setPaladinLabel("1");
          break;
        }
        // the troop was not found
        else {
          TroopsDetailPanel.setPaladinLabel("0");
        }
      } catch (NoSuchElementException e) {
      }
    }
  }
Exemple #3
0
  // Sends the population to the GUI
  public static void setPopulation() {

    try {
      String setPopulaton;
      setPopulaton =
          WebAutomation.driver.findElement(By.xpath("//*[@id=\"pop_current_label\"]")).getText();

      String setPopulationMax;
      setPopulationMax =
          WebAutomation.driver.findElement(By.xpath("//*[@id=\"pop_max_label\"]")).getText();

      TroopsDetailPanel.setPopulationCountLabel(setPopulaton + "/" + setPopulationMax);
    } catch (NoSuchElementException e) {
    } catch (StaleElementReferenceException e) {
    }
  }