// Sends the level of iron to the GUI public static void setIron() { for (int i = 2; i < 20; i++) { try { String ironLabel = WebAutomation.driver .findElement(By.xpath("//*[@id=\"buildings\"]/tbody/tr[" + i + "]/td[1]")) .getText(); if (substring(ironLabel, 0, 4).equals("Iron")) { BuildPanel.setIronLabel("Iron " + substring(ironLabel, 5, 20)); if (substring(ironLabel, 10, 20).equals("")) { BuildPanel.setIronLabel("Iron (Level 0)"); BuildPanel.setIronButtonTrueOrFalse(false); } break; } else { BuildPanel.setIronLabel("Iron (Level 0)"); } } catch (NoSuchElementException e) { BuildPanel.setUpgradeIronLabel("Cannot upgrade"); BuildPanel.setIronButtonTrueOrFalse(false); BuildPanel.setIronLabel("Iron max level"); } } }