diff --git a/documentation/chapters/event-system.md b/documentation/chapters/event-system.md index 6006679..c39390d 100644 --- a/documentation/chapters/event-system.md +++ b/documentation/chapters/event-system.md @@ -37,6 +37,7 @@ The `webtester-core` module provides events for all it's actions: - `ClickedEvent` - `DoubleClickedEvent` +- `FormSubmittedEvent` - `SelectedByIndexEvent` - `SelectedByTextEvent` - `SelectedByValueEvent` diff --git a/webtester-core/src/test/java/integration/pageobjects/FormIntegrationTest.java b/webtester-core/src/test/java/integration/pageobjects/FormIntegrationTest.java new file mode 100644 index 0000000..26e0dc6 --- /dev/null +++ b/webtester-core/src/test/java/integration/pageobjects/FormIntegrationTest.java @@ -0,0 +1,68 @@ +package integration.pageobjects; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +import org.junit.Before; +import org.junit.Test; + +import integration.AbstractWebTesterIntegrationTest; + +import info.novatec.testit.webtester.api.annotations.IdentifyUsing; +import info.novatec.testit.webtester.api.exceptions.WrongElementClassException; +import info.novatec.testit.webtester.pageobjects.Form; +import info.novatec.testit.webtester.pageobjects.PageObject; + + + +public class FormIntegrationTest extends AbstractWebTesterIntegrationTest{ + + FormTestPage page; + + @Before + public void initPage() { + page = getBrowser().create(FormTestPage.class); + } + + @Override + protected String getHTMLFilePath() { + return "html/pageobjects/form.html"; + } + + /* submit */ + + @Test + public final void testThatSubmitDelegatesToTargetPage() { + page.form.submit(); + assertThat(getBrowser().getPageTitle().equals("Target Page"), is(true)); + } + + @Test(expected = WrongElementClassException.class) + public final void testThatSubmitFailsIfNoFormIsGiven() { + page.notAForm.submit(); + } + + /* validation of mapping */ + + @Test + public final void testValidationOfMapping_form() { + assertPageObjectCanBeInitialized(page.form); + } + + @Test(expected = WrongElementClassException.class) + public final void testValidationOfMapping_noForm() { + assertPageObjectCanBeInitialized(page.notAForm); + } + + /* utilities */ + + public static class FormTestPage extends PageObject { + + @IdentifyUsing("form") + Form form; + + @IdentifyUsing("notAForm") + Form notAForm; + + } +} diff --git a/webtester-core/src/test/resources/html/pageobjects/form.html b/webtester-core/src/test/resources/html/pageobjects/form.html new file mode 100644 index 0000000..ab7815f --- /dev/null +++ b/webtester-core/src/test/resources/html/pageobjects/form.html @@ -0,0 +1,36 @@ + + +
+ + + + +A Form | ++ + | +
Not a Form | +This is not a DIV | +