private static void tickBox(CheckBox checkBox) { WebElement element = null; try { element = SEL_DRIVER.findElement( By.xpath("//*/input[contains(@name,'" + checkBox.getNametag() + "')]")); } catch (Exception exception) { try { element = SEL_DRIVER.findElement( By.xpath("//*/input[contains(@type,'" + checkBox.getNametag() + "')]")); } catch (Exception exception2) { try { element = SEL_DRIVER.findElement( By.xpath("//*/input[contains(@value,'" + checkBox.getNametag() + "')]")); } catch (Exception e2) { } } } System.out.println(checkBox.getNewValue()); if ((element.isSelected() && checkBox.getNewValue() == "false") || (!element.isSelected() && checkBox.getNewValue() != "false")) { element.click(); } }