// Sends number of light cal to the GUI public static void setLightCal() { // 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 lightCalLabel = WebAutomation.driver .findElement(By.xpath("//*[@id=\"show_units\"]/div/table/tbody/tr[" + i + "]")) .getText(); if (substring(lightCalLabel, 2, 7).equals("Light") || substring(lightCalLabel, 3, 8).equals("Light") || substring(lightCalLabel, 4, 9).equals("Light") || substring(lightCalLabel, 5, 10).equals("Light") || substring(lightCalLabel, 6, 11).equals("Light") || substring(lightCalLabel, 7, 12).equals("Light")) { TroopsDetailPanel.setLightCalLabel( WebAutomation.driver .findElement( By.xpath("//*[@id='show_units']/div/table/tbody/tr[" + i + "]/td/strong")) .getText()); break; } // the troop was not found else { TroopsDetailPanel.setLightCalLabel("0"); } } catch (NoSuchElementException e) { } } }