/** * Test that ByLabel works for CheckBoxes by label id. */ @Test public void testFindByLabelId() { // Launch the web browser to the LDE WebDriver driver = getDriver(); WContainer container = (WContainer) getUi(); WFieldLayout layout = (WFieldLayout) container.getChildAt(0); WField field = (WField) layout.getChildAt(0); String labelId = field.getLabel().getId(); String componentId = field.getField().getId(); WebElement checkBox = driver.findElement(new ByLabel(labelId)); Assert.assertNotNull("Unable to find checkbox by labelId", checkBox); Assert.assertEquals("Checkbox element ID does not match expected", componentId, checkBox.getAttribute("id")); }
/** * Test that ByLabel works for CheckBoxes by label text exact match. */ @Test public void testFindByLabelTextExact() { // Launch the web browser to the LDE WebDriver driver = getDriver(); WContainer container = (WContainer) getUi(); WFieldLayout layout = (WFieldLayout) container.getChildAt(0); WField field = (WField) layout.getChildAt(0); String labelText = field.getLabel().getText(); String componentId = field.getField().getId(); WebElement checkBox = driver.findElement(new ByLabel(labelText, false)); Assert.assertNotNull("Unable to find checkbox by label text", checkBox); Assert.assertEquals("Checkbox element ID does not match expected", componentId, checkBox.getAttribute("id")); }