This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
webtester-core/src/test/java/integration/pageobjects/FormIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
webtester-core/src/test/resources/html/pageobjects/form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../_style.css"> | ||
</head> | ||
<body> | ||
|
||
<h1>Form Test Page</h1> | ||
<h3>This page contains elements for testing the functionality of the Form page fragment class.</h3> | ||
|
||
<hr> | ||
<br><br> | ||
|
||
<table> | ||
<tbody> | ||
<tr> | ||
<td>A Form</td> | ||
<td> | ||
<form id="form" action="_targetPage.html"> | ||
<input type="text"> | ||
<input type="text"> | ||
</form> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td>Not a Form</td> | ||
<td><span id="notAForm">This is not a DIV</span></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
<br><br> | ||
<hr> | ||
|
||
</body> | ||
</html> |