### Question:
Form extends AbstractElement implements Submitable { public void submit() { getDispatcher().beforeSubmit(this); getElement().submit(); getDispatcher().afterSubmit(this); } Form(String locator);  Form(String locator, String controlName);  Form(ParentTraits parent, String locator);  Form(String locator, String controlName, ParentTraits parent); void submit();  }### Answer:
@Test(groups = { "browser-tests" }, expectedExceptions = { UnhandledAlertException.class, NullPointerException.class }) @WebTest public void testSubmitNegativeTest() { Form searchForm = new Form(TestObjectRepository.FORM_SEARCH.getValue()); Grid.driver().get(TestServerUtils.getTestEditableURL()); try { searchForm.submit(); Grid.driver().getTitle(); } finally { AlertHandler.flushAllAlerts(); } }
@Test(groups = { "browser-tests" }) @WebTest public void testSubmitForm() { Form searchForm = new Form(TestObjectRepository.FORM_SEARCH.getValue()); try { Grid.driver().get(TestServerUtils.getTestEditableURL()); searchForm.submit(); } finally { AlertHandler.flushAllAlerts(); } }
@Test(groups = { "browser-tests" }) @WebTest public void testSubmitFormConstructor2() { String controlName = "searchForm"; Form searchForm2 = new Form(TestObjectRepository.FORM_SEARCH.getValue(), controlName); try { Grid.driver().get(TestServerUtils.getTestEditableURL()); searchForm2.submit(); } finally { AlertHandler.flushAllAlerts(); } }
@Test(groups = { "browser-tests" }) @WebTest public void testSubmitFormConstructor3() { ParentTraits parent = null; Form searchForm3 = new Form(parent, TestObjectRepository.FORM_SEARCH.getValue()); try { Grid.driver().get(TestServerUtils.getTestEditableURL()); searchForm3.submit(); } finally { AlertHandler.flushAllAlerts(); } }
@Test(groups = { "browser-tests" }) @WebTest public void testSubmitFormConstructor4() { ParentTraits parent = null; String controlName = "searchForm"; Form searchForm4 = new Form(TestObjectRepository.FORM_SEARCH.getValue(), controlName, parent); try { Grid.driver().get(TestServerUtils.getTestEditableURL()); searchForm4.submit(); } finally { AlertHandler.flushAllAlerts(); } }