// Sends the level of workshop to the GUI public static void setWorkShop() { for (int i = 2; i < 20; i++) { try { String workShopLabel = WebAutomation.driver .findElement(By.xpath("//*[@id=\"buildings\"]/tbody/tr[" + i + "]/td[1]")) .getText(); if (substring(workShopLabel, 0, 8).equals("Workshop")) { BuildPanel.setWorkShopLabel("Workshop " + substring(workShopLabel, 9, 19)); if (substring(workShopLabel, 9, 19).equals("")) { BuildPanel.setWorkShopLabel("Workshop (Level 0)"); BuildPanel.setWorkShopButtonTrueOrFalse(false); } break; } else { BuildPanel.setWorkShopLabel("Workshop (Level 0)"); } } catch (NoSuchElementException e) { BuildPanel.setUpgradeWorkShopLabel("Cannot upgrade"); BuildPanel.setWorkShopButtonTrueOrFalse(false); BuildPanel.setWorkShopLabel("Workshop max level"); } } }