FormService extends BaseServiceHub { public WebElement fillFormField_locator(String locator, String value) { WebElement fieldEl = seleniumElementService.translateLocatorToWebElement(locator); fieldEl.clear(); fieldEl.sendKeys(getReferenceService().namespaceString(value)); return fieldEl; } FormService(ElementService seleniumElementService); WebElement fillFormField_locator(String locator, String value); WebElement fillFormField_fromView(String viewName, String fieldName, String value); void isFormFieldOnViewSetTo(String viewName, String fieldName, String value); void setSelectOptionOnView(String viewName, String elementName, String optionText); void isOptionOfSelectForViewSelected(String viewName, String selectElementName, String optionText); void checkCheckboxOnView(String view, String checkboxRef); void uncheckCheckboxOnView(String view, String checkboxRef);  }
@Test public void testFillFormField_idLocator() throws IOException { seleniumNavigationService.navigate_to_url(SenBotContext.RESOURCE_LOCATION_PREFIX + "/test_pages/exampleForm.html"); String expected = "Some text"; seleniumFormService.fillFormField_locator(ElementService.ID_LOCATOR_PREFIX + "textField", expected); WebElement formElement = seleniumElementService.findExpectedElement(By.id("textField")); assertEquals(expected, formElement.getAttribute("value")); }
@Test public void testFillFormField_Locator_clearOnFill() throws IOException { seleniumNavigationService.navigate_to_url(SenBotContext.RESOURCE_LOCATION_PREFIX + "/test_pages/exampleForm.html"); String expected = "Some text"; seleniumFormService.fillFormField_locator(ElementService.ID_LOCATOR_PREFIX + "textField", expected); seleniumFormService.fillFormField_locator(ElementService.ID_LOCATOR_PREFIX + "textField", expected); WebElement formElement = seleniumElementService.findExpectedElement(By.id("textField")); assertEquals(expected, formElement.getAttribute("value")); }
@Test public void testFillFormField_Locator_passwordField() throws IOException { seleniumNavigationService.navigate_to_url(SenBotContext.RESOURCE_LOCATION_PREFIX + " String expected = "Some text"; seleniumFormService.fillFormField_locator(ElementService.ID_LOCATOR_PREFIX + "passwordField", expected); WebElement formElement = seleniumElementService.findExpectedElement(By.id("passwordField")); assertEquals(expected, formElement.getAttribute("value")); }
@Test public void testFillFormField_Locator_textareaField() throws IOException { seleniumNavigationService.navigate_to_url(SenBotContext.RESOURCE_LOCATION_PREFIX + " String expected = "Some text"; seleniumFormService.fillFormField_locator(ElementService.ID_LOCATOR_PREFIX + "areaField", expected); WebElement formElement = seleniumElementService.findExpectedElement(By.id("areaField")); assertEquals(expected, formElement.getAttribute("value")); }
@Test public void testFillFormField_Locator_textareaFieldNameSpace() throws IOException { seleniumNavigationService.navigate_to_url(SenBotContext.RESOURCE_LOCATION_PREFIX + " String expected = SenBotReferenceService.NAME_SPACE_PREFIX + "Some text"; seleniumFormService.fillFormField_locator(ElementService.ID_LOCATOR_PREFIX + "areaField", expected); WebElement formElement = seleniumElementService.findExpectedElement(By.id("areaField")); assertNotEquals(expected, formElement.getAttribute("value")); assertEquals(SenBotContext.getSenBotContext().getReferenceService().namespaceString(expected), formElement.getAttribute("value")); }