Revision: 454
Author: henryju
Date: 2006-05-17 03:03:17 -0700 (Wed, 17 May 2006)
ViewCVS: http://svn.sourceforge.net/jwebunit/?rev=454&view=rev
Log Message:
-----------
Rename reset() and resetForm() to resetDialog() and reset().
Add new Javascript tests.
Add user agent support to HttpUnit and HtmlUnit, and a new test.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
trunk/jwebunit-httpunit-plugin/src/test/java/net/sourceforge/jwebunit/httpunit/JWebUnitTest.java
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
trunk/jwebunit-jacobie-plugin/src/test/java/net/sourceforge/jwebunit/jacobie/JWebUnitTest.java
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
Added Paths:
-----------
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavascriptTest/
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavascriptTest/DocumentWrite.html
trunk/jwebunit-commons-tests/src/main/resources/testcases/TestContextTest/
trunk/jwebunit-commons-tests/src/main/resources/testcases/TestContextTest/testPage.html
Modified:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -27,13 +27,13 @@
public void testSetInputField() {
beginAt("/SingleNamedButtonForm.html");
- setFormElement("color", "blue");
+ setTextField("color", "blue");
submit("button");
assertTextPresent("Submitted parameters");
//dumpResponse(System.out);
assertTextPresent("Params are: color=blue");
clickLink("return");
- setFormElement("color", "red");
+ setTextField("color", "red");
submit();
assertTextPresent("Params are: color=red");
}
@@ -41,7 +41,7 @@
public void testCheckBoxSelection() {
beginAt("/SingleNamedButtonForm.html");
checkCheckbox("checkBox");
- setFormElement("color", "blue");
+ setTextField("color", "blue");
submit();
assertTextPresent("Params are: color=blue checkBox=on");
}
@@ -68,7 +68,7 @@
beginAt("/SingleNamedButtonForm.html");
checkCheckbox("checkBox");
assertFormElementEquals("checkBox", "on");
- setFormElement("color", "blue");
+ setTextField("color", "blue");
uncheckCheckbox("checkBox");
submit();
assertTextPresent("Params are: color=blue ");
@@ -76,14 +76,14 @@
public void testSingleFormSingleUnnamedButtonSubmission() {
beginAt("/SingleUnnamedButtonForm.html");
- setFormElement("color", "blue");
+ setTextField("color", "blue");
submit();
assertTextPresent(" color=blue ");
}
public void testSingleNamedButtonSubmission() {
beginAt("/SingleNamedButtonForm.html");
- setFormElement("color", "red");
+ setTextField("color", "red");
submit();
assertTextPresent("Params are: color=red");
}
@@ -100,7 +100,7 @@
public void testBogusParameter() {
gotoMultiButtonPage();
try {
- setFormElement("nonexistent", "anyvalue");
+ setTextField("nonexistent", "anyvalue");
} catch (AssertionFailedError e) {
return;
}
@@ -109,9 +109,9 @@
public void testParamSetOnMultiForm() {
beginAt("/MultiFormPage.html");
- setFormElement("param1", "anyvalue");
+ setTextField("param1", "anyvalue");
setWorkingForm("form2");
- setFormElement("param2", "anyvalue");
+ setTextField("param2", "anyvalue");
submit("button2a");
assertTextPresent("param2=anyvalue");
}
@@ -134,28 +134,27 @@
public void testUnnamedSubmitOnSpecificForm() {
beginAt("/MultiFormPage.html");
- setFormElement("param4", "anyvalue");
+ setTextField("param4", "anyvalue");
submit();
assertTextPresent("param4=anyvalue");
}
public void testNamedSubmitOnSpecificForm() {
beginAt("/MultiFormPage.html");
- setFormElement("param2", "anyvalue");
+ setTextField("param2", "anyvalue");
submit("button2b");
assertTextPresent(" param2=anyvalue ");
assertTextPresent(" button2b=b2b ");
}
- //TODO Test Reset without using getResponse
-// public void testSubmissionReset() {
-// beginAt("/MultiFormPage.html");
-// setFormElement("param2", "anyvalue");
-// WebResponse oldResp = getDialog().getResponse();
-// submit("button2b");
-// assertFalse(getDialog().hasForm());
-// assertTrue(getDialog().getResponse() != oldResp);
-// }
+ public void testSubmissionReset() {
+ beginAt("/MultiFormPage.html");
+ setTextField("param2", "anyvalue");
+ reset();
+ submit("button2b");
+ assertTextNotPresent(" param2=anyvalue ");
+ assertTextPresent(" button2b=b2b ");
+ }
public void testSelectOption() {
beginAt("/MultiFormPage.html");
Modified:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FramesAndWindowsTest.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -97,30 +97,30 @@
beginAt("InlineFrame.html");
assertTextPresent("TopFrame");
// Is this how it should work? see also the test below
- assertTextNotPresent("<p>ContentFrame</p>");
+ assertTextNotPresent("ContentFrame");
gotoFrame("ContentFrame");
- assertTextPresent("<p>ContentFrame</p>"); // only
'ContentFrame' matches frameset tag too
+ assertTextPresent("ContentFrame"); // only 'ContentFrame'
matches frameset tag too
}
public void testFormInputInFrame() {
beginAt("Frames.html");
gotoFrame("ContentFrame");
assertFormPresent();
- setFormElement("color", "red");
+ setTextField("color", "red");
submit("submit");
- // TODO should it bee nessecary to select frame again?
+ // TODO should it be necessary to select frame again?
gotoRootWindow();
gotoFrame("ContentFrame");
assertTextPresent(" color=red ");
}
- /* this just posts to a new frameset inside the frame, is the test
needed?
+ //TODO this just posts to a new frameset inside the frame, is the test
needed?
public void testFormInputInFrameToFrame() {
beginAt("Frames.html");
gotoFrame("ContentFrame");
- setFormElement("color", "green");
+ setTextField("color", "green");
submit();
- assertTitleEquals("Frames2");
- } */
+ assertTitleEquals("Submitted parameters");
+ }
}
Modified:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/TestContextTest.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -5,8 +5,6 @@
*/
package net.sourceforge.jwebunit.tests;
-import junit.framework.TestCase;
-
import javax.servlet.http.Cookie;
import net.sourceforge.jwebunit.TestContext;
@@ -14,14 +12,15 @@
import java.util.List;
import java.util.Locale;
-public class TestContextTest extends TestCase {
+public class TestContextTest extends JWebUnitAPITestCase {
private TestContext context;
public TestContextTest(String s) {
super(s);
}
- protected void setUp() throws Exception {
+ public void setUp() throws Exception {
+ super.setUp();
context = new TestContext();
context.setAuthorization("user", "pwd");
context.addCookie("key", "val");
@@ -49,8 +48,13 @@
assertEquals(name, context.getResourceBundleName());
}
- public void testBaseUrl() {
-
+ public void testUserAgent() {
+ getTestContext().setBaseUrl(HOST_PATH + "/TestContextTest");
+ String userAgent = "Mozilla/5.0 (X11; U; Linux i686; en-US;
rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3";
+ getTestContext().setUserAgent(userAgent);
+ beginAt("/testPage.html");
+ dumpResponse(System.out);
+ assertTextPresent("Browser user-agent: "+userAgent);
}
}
Added:
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavascriptTest/DocumentWrite.html
===================================================================
---
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavascriptTest/DocumentWrite.html
(rev 0)
+++
trunk/jwebunit-commons-tests/src/main/resources/testcases/JavascriptTest/DocumentWrite.html
2006-05-17 10:03:17 UTC (rev 454)
@@ -0,0 +1,8 @@
+<HTML>
+ <BODY>
+ <SCRIPT LANGUAGE="javascript">
+ document.write("Hello ");
+ document.write("World");
+ </SCRIPT>
+ </BODY>
+<HTML>
\ No newline at end of file
Added:
trunk/jwebunit-commons-tests/src/main/resources/testcases/TestContextTest/testPage.html
===================================================================
---
trunk/jwebunit-commons-tests/src/main/resources/testcases/TestContextTest/testPage.html
(rev 0)
+++
trunk/jwebunit-commons-tests/src/main/resources/testcases/TestContextTest/testPage.html
2006-05-17 10:03:17 UTC (rev 454)
@@ -0,0 +1,10 @@
+<HTML>
+ <BODY>
+ <SCRIPT LANGUAGE="javascript">
+ document.write("Browser code name: "
+navigator.appCodeName);
+ document.write("Browser name: " +navigator.appName);
+ document.write("Browser version:
"+navigator.appVersion);
+ document.write("Browser user-agent:
"+navigator.userAgent);
+ </SCRIPT>
+ </BODY>
+<HTML>
\ No newline at end of file
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
===================================================================
---
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/IJWebUnitDialog.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -27,6 +27,11 @@
void beginAt(String aInitialURL, TestContext aTestContext) throws
TestingEngineResponseException;
/**
+ * Reset the dialog for the next test.
+ */
+ void resetDialog() throws TestingEngineResponseException;
+
+ /**
* Test if the window with the given name is in the current conversation.
*
* @param windowName
@@ -39,23 +44,31 @@
boolean isWindowByTitlePresent(String title);
/**
- * Return the string representation of the current response, encoded as
specified by the current
+ * Return the string representation of the current page, encoded as
specified by the current
* [EMAIL PROTECTED] net.sourceforge.jwebunit.TestContext}.
*/
- String getResponseText();
-
+ String getPageText();
+
/**
* Return the page title of the current response page, encoded as
specified by the current
* [EMAIL PROTECTED] net.sourceforge.jwebunit.TestContext}.
*/
- String getResponsePageTitle();
-
+ String getPageTitle();
+
+ /**
+ * Test if a cookie is present with given name.
+ * @param cookieName name of the cookie.
+ * @return true if the cookie is present.
+ */
boolean hasCookie(String cookieName);
+ /**
+ * Get cookie value.
+ * @param cookieName name of the cookie.
+ * @return value of the cookie.
+ */
String getCookieValue(String cookieName);
- //TODO: Move other dump methods to dialog!!
- //WebForm getForm();
/**
* Enable or disable Javascript support
@@ -99,11 +112,10 @@
* name of the input element
* @param paramValue
* parameter value to submit for the element.
+ * @deprecated use setTextField, checkCheckBox, ...
*/
void setFormParameter(String paramName, String paramValue);
- void updateFormParameter(String paramName, String paramValue);
-
/**
* Return the current value of a form input element.
*
@@ -113,18 +125,6 @@
String getFormParameterValue(String paramName);
/**
- * Specify that no parameter value should be submitted for a given input
element. Typically used to uncheck check
- * boxes.
- *
- * @param paramName
- * name of the input element.
- */
- void removeFormParameter(String paramName);
-
- void removeFormParameterWithValue(String paramName,
- String value);
-
- /**
* Return true if a form parameter (input element) is present on the
current response preceded by a given label.
*
* @param paramLabel
@@ -145,6 +145,16 @@
boolean hasSubmitButton(String buttonName);
boolean hasSubmitButton(String buttonName, String buttonValue);
+
+ /**
+ * Fill a text or password field with the provided value.
+ *
+ * @param inputName
+ * name of the text or password input element
+ * @param textOrPasswd
+ * value to type in the field.
+ */
+ void setTextField(String inputName, String textOrPasswd);
/**
* Checks if a button with <code>text</code> is present.
@@ -248,15 +258,10 @@
void submit(String buttonName, String buttonValue);
/**
- * Reset the Dialog for the next test. This is not reset Form.
- */
- void reset() throws TestingEngineResponseException;
-
- /**
* Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
* the current form is established.
*/
- void resetForm();
+ void reset();
/**
* Return true if a link is present in the current response containing the
specified text (note that HttpUnit uses
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
2006-05-15 07:05:17 UTC (rev 453)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTestCase.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -45,7 +45,7 @@
//this resets the dialog / nulls out objects, etc.
//close IE from the JacobieDialog.
- reset();
+ resetDialog();
super.tearDown();
}
@@ -101,6 +101,10 @@
getTester().beginAt(relativeURL);
}
+ public void resetDialog() {
+ getTester().resetDialog();
+ }
+
public String getMessage(String key) {
return getTester().getMessage(key);
}
@@ -509,9 +513,18 @@
getTester().setWorkingForm(nameOrId);
}
+ /**
+ * @deprecated use setTextField or others methods
+ * @param formElementName
+ * @param value
+ */
public void setFormElement(String formElementName, String value) {
getTester().setFormElement(formElementName, value);
}
+
+ public void setTextField(String textFieldName, String value) {
+ getTester().setTextField(textFieldName, value);
+ }
public void setFormElementWithLabel(String formElementLabel, String value)
{
getTester().setFormElementWithLabel(formElementLabel, value);
@@ -559,16 +572,12 @@
getTester().submit(buttonName, buttonValue);
}
- public void reset() {
- getTester().reset();
- }
-
/**
* Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
* the current form is established.
*/
- public void resetForm() {
- getTester().resetForm();
+ public void reset() {
+ getTester().reset();
}
public void clickLinkWithText(String linkText) {
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
2006-05-15 07:05:17 UTC (rev 453)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -97,7 +97,19 @@
return theIJWebUnitDialog;
}
-
+
+ /**
+ * Reset the current Dialog
+ * @see resetForm to reset a form in the response.
+ */
+ public void resetDialog() {
+ try {
+ getDialog().resetDialog();
+ } catch (TestingEngineResponseException
aTestingEngineResponseException) {
+
handleTestingEngineResponseException(aTestingEngineResponseException);
+ }
+ }
+
public void setDialog(IJWebUnitDialog aIJWebUnitDialog) {
dialog = aIJWebUnitDialog;
}
@@ -180,7 +192,7 @@
* expected title value
*/
public void assertTitleEquals(String title) {
- Assert.assertEquals(title, getDialog().getResponsePageTitle());
+ Assert.assertEquals(title, getDialog().getPageTitle());
}
/**
@@ -198,7 +210,7 @@
Assert.fail(e.toString());
}
Assert.assertTrue("Unable to match [" + regexp + "] in title",
- re.match(getDialog().getResponsePageTitle()));
+ re.match(getDialog().getPageTitle()));
}
/**
@@ -210,7 +222,7 @@
*/
public void assertTitleEqualsKey(String titleKey) {
Assert.assertEquals(getMessage(titleKey), getDialog()
- .getResponsePageTitle());
+ .getPageTitle());
}
/**
@@ -1408,12 +1420,26 @@
* @param formElementName
* name of form element.
* @param value
+ * @deprecated use setTextField or other methods
*/
public void setFormElement(String formElementName, String value) {
assertFormPresent();
assertFormElementPresent(formElementName);
getDialog().setFormParameter(formElementName, value);
}
+
+ /**
+ * Set the value of a text or password input field.
+ *
+ * @param inputName
+ * name of form element.
+ * @param value value to set.
+ */
+ public void setTextField(String inputName, String value) {
+ assertFormPresent();
+ assertFormElementPresent(inputName);
+ getDialog().setTextField(inputName, value);
+ }
/**
* Set the value of a form input element. The element is identified by a
@@ -1549,24 +1575,12 @@
getDialog().submit(buttonName, buttonValue);
}
- /**
- * Reset the current Dialog
- * @see resetForm to reset a form in the response.
- */
- public void reset() {
- try {
- getDialog().reset();
- } catch (TestingEngineResponseException
aTestingEngineResponseException) {
-
handleTestingEngineResponseException(aTestingEngineResponseException);
- }
- }
-
/**
* Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
* the current form is established.
*/
- public void resetForm() {
- getDialog().resetForm();
+ public void reset() {
+ getDialog().reset();
}
Modified:
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
===================================================================
---
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitDialog.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -8,7 +8,6 @@
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.log4j.Logger;
import java.io.IOException;
@@ -30,6 +29,7 @@
import net.sourceforge.jwebunit.IJWebUnitDialog;
import net.sourceforge.jwebunit.TestContext;
+import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
import com.gargoylesoftware.htmlunit.Page;
import com.gargoylesoftware.htmlunit.TextPage;
@@ -70,20 +70,32 @@
*/
public class HtmlUnitDialog implements IJWebUnitDialog {
/**
- * Logger for this class
+ * Logger for this class.
*/
- private static final Logger logger =
Logger.getLogger(HtmlUnitDialog.class);
+ private static final Logger LOGGER =
Logger.getLogger(HtmlUnitDialog.class);
+ /**
+ * Encapsulate browser abilities.
+ */
private WebClient wc;
+ /**
+ * The currently selected window.
+ */
private WebWindow win;
+ /**
+ * A ref to the test context.
+ */
private TestContext testContext;
+ /**
+ * The currently selected form.
+ */
private HtmlForm form;
/**
- * Is Javascript enabled
+ * Is Javascript enabled.
*/
private boolean jsEnabled = true;
@@ -116,6 +128,15 @@
}
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see net.sourceforge.jwebunit.IJWebUnitDialog#reset()
+ */
+ public void resetDialog() throws TestingEngineResponseException {
+ // Nothing to do
+ }
+
public void gotoPage(String initialURL)
throws TestingEngineResponseException {
try {
@@ -135,7 +156,7 @@
}
private void initWebClient() {
- wc = new WebClient();
+ wc = new WebClient(new
BrowserVersion("htmlunit","1.8",testContext.getUserAgent(),"1.2",6));
wc.setJavaScriptEnabled(jsEnabled);
wc.addWebWindowListener(new WebWindowListener() {
public void webWindowClosed(WebWindowEvent event) {
@@ -145,7 +166,7 @@
}
String win = event.getWebWindow().getName();
Page oldPage = event.getOldPage();
- logger.info("Window " + win + " closed : "
+ LOGGER.info("Window " + win + " closed : "
+ ((HtmlPage) oldPage).getTitleText());
}
@@ -159,7 +180,7 @@
String newPageTitle = "non_html";
if (newPage instanceof HtmlPage)
newPageTitle = ((HtmlPage) newPage).getTitleText();
- logger.info("Window " + win + " changed : " + oldPageTitle
+ LOGGER.info("Window " + win + " changed : " + oldPageTitle
+ " became " + newPageTitle);
}
@@ -167,7 +188,7 @@
String win = event.getWebWindow().getName();
Page newPage = event.getNewPage();
if (newPage != null) {
- logger.info("Window " + win + " closed : "
+ LOGGER.info("Window " + win + " closed : "
+ ((HtmlPage) newPage).getTitleText());
}
}
@@ -460,7 +481,7 @@
* @param paramValue
* parameter value to submit for the element.
*/
- public void setFormTextOrPassword(String fieldName, String paramValue) {
+ public void setTextField(String fieldName, String paramValue) {
checkFormStateWithInput(fieldName);
getForm().getInputByName(fieldName).setValueAttribute(paramValue);
}
@@ -610,11 +631,9 @@
* string to check for.
*/
public boolean isTextInResponse(String text) {
- return (getTestContext().toEncodedString(
- win.getEnclosedPage().getWebResponse().getContentAsString())
- .indexOf(text) >= 0);
+ return getPageText().indexOf(text) >= 0;
}
-
+
/**
* Return true if given regexp has a match anywhere in the current
response.
*
@@ -811,7 +830,7 @@
* Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
* the current form is established.
*/
- public void resetForm() {
+ public void reset() {
getForm().reset();
}
@@ -1524,7 +1543,8 @@
* @see
net.sourceforge.jwebunit.IJWebUnitDialog#getFormElementValueBeforeLabel(java.lang.String)
*/
public String getFormElementValueBeforeLabel(String formElementLabel) {
- throw new
UnsupportedOperationException("getFormElementValueBeforeLabel");
+ throw new UnsupportedOperationException(
+ "getFormElementValueBeforeLabel");
}
/*
@@ -1556,19 +1576,18 @@
*
* @see net.sourceforge.jwebunit.IJWebUnitDialog#getResponsePageTitle()
*/
- public String getResponsePageTitle() {
+ public String getPageTitle() {
return getCurrentPageTitle();
}
- /*
- * (non-Javadoc)
- *
- * @see net.sourceforge.jwebunit.IJWebUnitDialog#getResponseText()
- */
- public String getResponseText() {
+ public String getPageHtml() {
return getCurrentPage().getWebResponse().getContentAsString();
}
+ public String getPageText() {
+ return ((HtmlPage)getCurrentPage()).asText();
+ }
+
/*
* (non-Javadoc)
*
@@ -1679,7 +1698,7 @@
* java.lang.String)
*/
public void setFormParameter(String paramName, String paramValue) {
- setFormTextOrPassword(paramName, paramValue);
+ setTextField(paramName, paramValue);
}
/*
@@ -1716,15 +1735,6 @@
/*
* (non-Javadoc)
*
- * @see net.sourceforge.jwebunit.IJWebUnitDialog#reset()
- */
- public void reset() throws TestingEngineResponseException {
- // Nothing to do
- }
-
- /*
- * (non-Javadoc)
- *
* @see
net.sourceforge.jwebunit.IJWebUnitDialog#setScriptingEnabled(boolean)
*/
public void setScriptingEnabled(boolean value) {
Modified:
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
===================================================================
---
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-htmlunit-plugin/src/test/java/net/sourceforge/jwebunit/htmlunit/JWebUnitTest.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -33,6 +33,7 @@
suite.addTestSuite(TableAssertionsTest.class);
suite.addTestSuite(ExpectedTableAssertionsTest.class);
suite.addTestSuite(JavaScriptEventsTest.class);
+ suite.addTestSuite(JavaScriptTest.class);
suite.addTestSuite(HelloWorldTest.class);
suite.addTestSuite(ExpectedTableTest.class);
suite.addTestSuite(HtmlParsingTest.class);
Modified:
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
===================================================================
---
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-httpunit-plugin/src/main/java/net/sourceforge/jwebunit/httpunit/HttpUnitDialog.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -96,6 +96,8 @@
private void initWebClient() {
wc = new WebConversation();
+
+ wc.getClientProperties().setUserAgent(testContext.getUserAgent());
wc.addClientListener(new WebClientListener() {
public void requestSent(WebClient webClient, WebRequest
webRequest) {
@@ -152,7 +154,7 @@
* Return the string representation of the current response, encoded as
* specified by the current [EMAIL PROTECTED]
net.sourceforge.jwebunit.TestContext}.
*/
- public String getResponseText() {
+ public String getPageText() {
try {
return getTestContext().toEncodedString(resp.getText());
} catch (IOException e) {
@@ -164,7 +166,7 @@
* Return the page title of the current response page, encoded as specified
* by the current [EMAIL PROTECTED] net.sourceforge.jwebunit.TestContext}.
*/
- public String getResponsePageTitle() {
+ public String getPageTitle() {
try {
return getTestContext().toEncodedString(resp.getTitle());
} catch (SAXException e) {
@@ -371,6 +373,10 @@
resp = getWebClient().getCurrentPage();
}
}
+
+ public void setTextField(String paramName, String paramValue) {
+ setFormParameter(paramName, paramValue);
+ }
public void updateFormParameter(String paramName, String paramValue) {
checkFormStateWithParameter(paramName);
@@ -842,14 +848,14 @@
/**
* Resets the Dialog
*/
- public void reset() throws TestingEngineResponseException {
+ public void resetDialog() throws TestingEngineResponseException {
}
/**
* Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
* the current form is established.
*/
- public void resetForm() {
+ public void reset() {
getForm().reset();
}
@@ -1462,7 +1468,7 @@
*/
public void dumpResponse(PrintStream stream) {
try {
- stream.println(getResponseText());
+ stream.println(getPageText());
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e.getMessage());
@@ -1589,5 +1595,4 @@
HttpUnitOptions.setScriptingEnabled(value);
}
-
}
\ No newline at end of file
Modified:
trunk/jwebunit-httpunit-plugin/src/test/java/net/sourceforge/jwebunit/httpunit/JWebUnitTest.java
===================================================================
---
trunk/jwebunit-httpunit-plugin/src/test/java/net/sourceforge/jwebunit/httpunit/JWebUnitTest.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-httpunit-plugin/src/test/java/net/sourceforge/jwebunit/httpunit/JWebUnitTest.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -33,6 +33,7 @@
suite.addTestSuite(TableAssertionsTest.class);
suite.addTestSuite(ExpectedTableAssertionsTest.class);
suite.addTestSuite(JavaScriptEventsTest.class);
+ suite.addTestSuite(JavaScriptTest.class);
suite.addTestSuite(HelloWorldTest.class);
suite.addTestSuite(ExpectedTableTest.class);
suite.addTestSuite(HtmlParsingTest.class);
Modified:
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
===================================================================
---
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-jacobie-plugin/src/main/java/net/sourceforge/jwebunit/jacobie/JacobieDialog.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -107,7 +107,7 @@
/**
* Resets all private variables contained by this class.
*/
- public void reset() throws TestingEngineResponseException {
+ public void resetDialog() throws TestingEngineResponseException {
resetIE();
}
@@ -115,8 +115,8 @@
* Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
* the current form is established.
*/
- public void resetForm() {
- throw new UnsupportedOperationException("resetForm");
+ public void reset() {
+ throw new UnsupportedOperationException("reset");
}
/**
@@ -136,7 +136,7 @@
}
- public String getResponsePageTitle() {
+ public String getPageTitle() {
String theString = null;
try {
theString = getIe().getDocument().getTitle().trim();
@@ -234,6 +234,10 @@
theDefaultHTMLElement.blur();
}
}
+
+ public void setTextField(String paramName, String paramValue) {
+ setFormParameter(paramName, paramValue);
+ }
/**
* Return true if a radio group contains the indicated option.
@@ -989,7 +993,7 @@
/* (non-Javadoc)
* @see net.sourceforge.jwebunit.IJWebUnitDialog#getResponseText()
*/
- public String getResponseText() {
+ public String getPageText() {
// TODO Auto-generated method stub
return null;
}
Modified:
trunk/jwebunit-jacobie-plugin/src/test/java/net/sourceforge/jwebunit/jacobie/JWebUnitTest.java
===================================================================
---
trunk/jwebunit-jacobie-plugin/src/test/java/net/sourceforge/jwebunit/jacobie/JWebUnitTest.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-jacobie-plugin/src/test/java/net/sourceforge/jwebunit/jacobie/JWebUnitTest.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -33,6 +33,7 @@
suite.addTestSuite(TableAssertionsTest.class);
suite.addTestSuite(ExpectedTableAssertionsTest.class);
suite.addTestSuite(JavaScriptEventsTest.class);
+ suite.addTestSuite(JavaScriptTest.class);
suite.addTestSuite(HelloWorldTest.class);
suite.addTestSuite(ExpectedTableTest.class);
suite.addTestSuite(HtmlParsingTest.class);
Modified:
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
===================================================================
---
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-selenium-plugin/src/main/java/net/sourceforge/jwebunit/selenium/SeleniumDialog.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -8,7 +8,7 @@
import org.apache.regexp.RE;
import org.apache.regexp.RESyntaxException;
-import org.openqa.selenium.server.SeleniumServer;
+//import org.openqa.selenium.server.SeleniumServer;
import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
import net.sourceforge.jwebunit.exception.UnableToSetFormException;
@@ -31,7 +31,7 @@
private DefaultSelenium selenium;
- private static SeleniumServer server;
+ // private static SeleniumServer server;
private static final int port = 4444;
@@ -40,15 +40,15 @@
private String form = null;
public SeleniumDialog() {
- if (server == null) {
- try {
- server = new SeleniumServer(port);
- server.start();
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
+// if (server == null) {
+// try {
+// server = new SeleniumServer(port);
+// server.start();
+// } catch (Exception e) {
+// e.printStackTrace();
+// throw new RuntimeException(e);
+// }
+// }
}
/**
@@ -198,7 +198,7 @@
* @param paramValue
* parameter value to submit for the element.
*/
- public void setFormTextOrPassword(String fieldName, String paramValue) {
+ public void setTextField(String fieldName, String paramValue) {
selenium.type(fieldName, paramValue);
}
@@ -885,7 +885,7 @@
*
* @see net.sourceforge.jwebunit.IJWebUnitDialog#getResponsePageTitle()
*/
- public String getResponsePageTitle() {
+ public String getPageTitle() {
// TODO Auto-generated method stub
return null;
}
@@ -895,7 +895,7 @@
*
* @see net.sourceforge.jwebunit.IJWebUnitDialog#getResponseText()
*/
- public String getResponseText() {
+ public String getPageText() {
// TODO Auto-generated method stub
return null;
}
@@ -1055,9 +1055,9 @@
/*
* (non-Javadoc)
*
- * @see net.sourceforge.jwebunit.IJWebUnitDialog#resetForm()
+ * @see net.sourceforge.jwebunit.IJWebUnitDialog#resetDialog()
*/
- public void resetForm() {
+ public void resetDialog() {
// TODO Auto-generated method stub
}
Modified:
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
===================================================================
---
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
2006-05-15 07:05:17 UTC (rev 453)
+++
trunk/jwebunit-selenium-plugin/src/test/java/net/sourceforge/jwebunit/selenium/JWebUnitTest.java
2006-05-17 10:03:17 UTC (rev 454)
@@ -33,6 +33,7 @@
suite.addTestSuite(TableAssertionsTest.class);
suite.addTestSuite(ExpectedTableAssertionsTest.class);
suite.addTestSuite(JavaScriptEventsTest.class);
+ suite.addTestSuite(JavaScriptTest.class);
suite.addTestSuite(HelloWorldTest.class);
suite.addTestSuite(ExpectedTableTest.class);
suite.addTestSuite(HtmlParsingTest.class);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development