Thread: [JWebUnit-development] SF.net SVN: jwebunit:[974] trunk (Page 6)
Brought to you by:
henryju
|
From: <he...@us...> - 2014-03-17 11:02:32
|
Revision: 974
http://sourceforge.net/p/jwebunit/code/974
Author: henryju
Date: 2014-03-17 11:02:29 +0000 (Mon, 17 Mar 2014)
Log Message:
-----------
[maven-release-plugin] prepare for next development iteration
Modified Paths:
--------------
trunk/jwebunit-code-generator/pom.xml
trunk/jwebunit-commons-tests/pom.xml
trunk/jwebunit-core/pom.xml
trunk/jwebunit-htmlunit-plugin/pom.xml
trunk/jwebunit-webdriver-plugin/pom.xml
trunk/pom.xml
Modified: trunk/jwebunit-code-generator/pom.xml
===================================================================
--- trunk/jwebunit-code-generator/pom.xml 2014-03-17 11:02:21 UTC (rev 973)
+++ trunk/jwebunit-code-generator/pom.xml 2014-03-17 11:02:29 UTC (rev 974)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.2</version>
+ <version>3.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-commons-tests/pom.xml
===================================================================
--- trunk/jwebunit-commons-tests/pom.xml 2014-03-17 11:02:21 UTC (rev 973)
+++ trunk/jwebunit-commons-tests/pom.xml 2014-03-17 11:02:29 UTC (rev 974)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.2</version>
+ <version>3.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-core/pom.xml
===================================================================
--- trunk/jwebunit-core/pom.xml 2014-03-17 11:02:21 UTC (rev 973)
+++ trunk/jwebunit-core/pom.xml 2014-03-17 11:02:29 UTC (rev 974)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.2</version>
+ <version>3.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/pom.xml 2014-03-17 11:02:21 UTC (rev 973)
+++ trunk/jwebunit-htmlunit-plugin/pom.xml 2014-03-17 11:02:29 UTC (rev 974)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.2</version>
+ <version>3.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/jwebunit-webdriver-plugin/pom.xml
===================================================================
--- trunk/jwebunit-webdriver-plugin/pom.xml 2014-03-17 11:02:21 UTC (rev 973)
+++ trunk/jwebunit-webdriver-plugin/pom.xml 2014-03-17 11:02:29 UTC (rev 974)
@@ -2,7 +2,7 @@
<parent>
<artifactId>jwebunit</artifactId>
<groupId>net.sourceforge.jwebunit</groupId>
- <version>3.2</version>
+ <version>3.3-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-03-17 11:02:21 UTC (rev 973)
+++ trunk/pom.xml 2014-03-17 11:02:29 UTC (rev 974)
@@ -3,7 +3,7 @@
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit</artifactId>
<name>JWebUnit</name>
- <version>3.2</version>
+ <version>3.3-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
JWebUnit is a Java framework that facilitates creation of
@@ -183,9 +183,9 @@
</license>
</licenses>
<scm>
- <connection>scm:svn:http://jwebunit.svn.sourceforge.net/svnroot/jwebunit/tags/jwebunit-3.2</connection>
- <developerConnection>scm:svn:https://jwebunit.svn.sourceforge.net/svnroot/jwebunit/tags/jwebunit-3.2</developerConnection>
- <url>http://jwebunit.svn.sourceforge.net/viewvc/jwebunit/tags/jwebunit-3.2</url>
+ <connection>scm:svn:http://jwebunit.svn.sourceforge.net/svnroot/jwebunit/trunk</connection>
+ <developerConnection>scm:svn:https://jwebunit.svn.sourceforge.net/svnroot/jwebunit/trunk</developerConnection>
+ <url>http://jwebunit.svn.sourceforge.net/viewvc/jwebunit/trunk</url>
</scm>
<organization>
<name>SourceForge</name>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jev...@us...> - 2014-03-17 23:23:28
|
Revision: 976
http://sourceforge.net/p/jwebunit/code/976
Author: jevonwright
Date: 2014-03-17 23:23:25 +0000 (Mon, 17 Mar 2014)
Log Message:
-----------
Adding methods hasElementById(), hasElementByXPath(), hasElementsByXPath() so one can test for elements without having to catch AssertionErrors as per getElementById() etc.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
Property Changed:
----------------
trunk/
Index: trunk
===================================================================
--- trunk 2014-03-17 11:04:26 UTC (rev 975)
+++ trunk 2014-03-17 23:23:25 UTC (rev 976)
Property changes on: trunk
___________________________________________________________________
Modified: svn:ignore
## -1,3 +1,4 ##
target
.project
.settings
+bin
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2014-03-17 11:04:26 UTC (rev 975)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/IElementTest.java 2014-03-17 23:23:25 UTC (rev 976)
@@ -18,22 +18,8 @@
*/
package net.sourceforge.jwebunit.tests;
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertCommentNotPresent;
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertCommentPresent;
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertElementPresent;
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertFormElementPresent;
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertMatch;
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertNotMatch;
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertTextFieldEquals;
-import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
-import static net.sourceforge.jwebunit.junit.JWebUnit.getElementById;
-import static net.sourceforge.jwebunit.junit.JWebUnit.getElementByXPath;
-import static net.sourceforge.jwebunit.junit.JWebUnit.getElementsByXPath;
-import static net.sourceforge.jwebunit.junit.JWebUnit.setBaseUrl;
-import static net.sourceforge.jwebunit.junit.JWebUnit.setTextField;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static net.sourceforge.jwebunit.junit.JWebUnit.*;
+import static org.junit.Assert.*;
import java.util.Date;
import java.util.List;
@@ -65,8 +51,23 @@
assertEquals(element.getAttribute("id"), "test");
assertEquals(element.getAttribute("value"), "test3");
}
+
+ @Test
+ public void testSimpleHasID() {
+ assertTrue(hasElementById("test"));
+ }
@Test
+ public void testSimpleHasXPath() {
+ assertTrue(hasElementByXPath("//input[@id='test']"));
+ }
+
+ @Test
+ public void testSimpleHasXPaths() {
+ assertTrue(hasElementsByXPath("//input[@id='test']"));
+ }
+
+ @Test
public void testMissing() {
// a missing element should throw an exception
try {
@@ -77,6 +78,21 @@
}
}
+ @Test
+ public void testMissingHasID() {
+ assertFalse(hasElementById("test2"));
+ }
+
+ @Test
+ public void testMissingHasXPath() {
+ assertFalse(hasElementByXPath("//input[@id='test2']"));
+ }
+
+ @Test
+ public void testMissingHasXPaths() {
+ assertFalse(hasElementsByXPath("//input[@id='test2']"));
+ }
+
/**
* Test parent, child methods
*/
Modified: trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2014-03-17 11:04:26 UTC (rev 975)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/junit/WebTester.java 2014-03-17 23:23:25 UTC (rev 976)
@@ -2737,6 +2737,16 @@
return getTestingEngine().getElementByXPath(xpath);
}
+ /**
+ * Return {@code true} if the given element by XPath exists.
+ *
+ * @param xpath XPath to search
+ * @return {@code true} if the the requested element
+ * @throws AssertionError if the element xpath is not found
+ */
+ public boolean hasElementByXPath(String xpath) {
+ return getTestingEngine().getElementByXPath(xpath) != null;
+ }
/**
* Get an element for a particular ID.
@@ -2749,6 +2759,16 @@
assertElementPresent(id);
return getTestingEngine().getElementByID(id);
}
+
+ /**
+ * Returns {@code true} if an element with the given ID exists.
+ *
+ * @param id element ID to find
+ * @return {@code true} if the element ID exists, {@code false} otherwise
+ */
+ public boolean hasElementById(String id) {
+ return getTestingEngine().getElementByID(id) != null;
+ }
/**
* Get elements for a particular xpath.
@@ -2760,6 +2780,17 @@
return getTestingEngine().getElementsByXPath(xpath);
}
+ /**
+ * Return {@code true} if the given elements by XPath exists.
+ *
+ * @param xpath XPath to search
+ * @return {@code true} if the given elements by XPath exist
+ */
+ public boolean hasElementsByXPath(String xpath) {
+ List<IElement> list = getTestingEngine().getElementsByXPath(xpath);
+ return list != null && !list.isEmpty();
+ }
+
// label methods
/**
* Assert a label for a given ID exists.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2015-07-13 15:52:15
|
Revision: 977
http://sourceforge.net/p/jwebunit/code/977
Author: henryju
Date: 2015-07-13 15:52:13 +0000 (Mon, 13 Jul 2015)
Log Message:
-----------
Update to HtmlUnit 2.17
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java
trunk/jwebunit-htmlunit-plugin/pom.xml
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/pom.xml
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java 2014-03-17 23:23:25 UTC (rev 976)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/CookiesServlet.java 2015-07-13 15:52:13 UTC (rev 977)
@@ -27,7 +27,7 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.eclipse.jetty.http.HttpHeaders;
+import org.eclipse.jetty.http.HttpHeader;
public class CookiesServlet extends HttpServlet {
@@ -95,12 +95,12 @@
jsessionIDCookie.setDomain("localhost");
response.addCookie(jsessionIDCookie);
- //With Jetty 6 we are now forced to access low level API to be able to set 2 same named cookies in the same response
+ //With Jetty 6+ we are now forced to access low level API to be able to set 2 same named cookies in the same response
org.eclipse.jetty.server.Response responseJetty = (org.eclipse.jetty.server.Response) response;
- String cookie1 = responseJetty.getHttpFields().getStringField(HttpHeaders.SET_COOKIE);
+ String cookie1 = responseJetty.getHttpFields().getStringField(HttpHeader.SET_COOKIE);
// 2
String cookie2 = cookie1.replace("worker1", "worker2");
- response.addHeader(HttpHeaders.SET_COOKIE, cookie2);
+ response.addHeader(HttpHeader.SET_COOKIE.asString(), cookie2);
}
}
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java 2014-03-17 23:23:25 UTC (rev 976)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/JettySetup.java 2015-07-13 15:52:13 UTC (rev 977)
@@ -25,11 +25,10 @@
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.DefaultHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.webapp.WebAppContext;
-import org.junit.AfterClass;
import org.junit.BeforeClass;
import static org.junit.Assert.fail;
@@ -60,9 +59,7 @@
if (!started) {
try {
jettyServer = new Server();
- SelectChannelConnector connector = new SelectChannelConnector();
- connector.setPort(JWebUnitAPITestCase.JETTY_PORT);
- connector.setAcceptors(5);
+ ServerConnector connector = new ServerConnector(jettyServer);
connector.setPort(JWebUnitAPITestCase.JETTY_PORT);
jettyServer.setConnectors(new Connector[] { connector });
Modified: trunk/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/pom.xml 2014-03-17 23:23:25 UTC (rev 976)
+++ trunk/jwebunit-htmlunit-plugin/pom.xml 2015-07-13 15:52:13 UTC (rev 977)
@@ -23,7 +23,7 @@
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
- <version>2.14</version>
+ <version>2.17</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2014-03-17 23:23:25 UTC (rev 976)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2015-07-13 15:52:13 UTC (rev 977)
@@ -169,7 +169,7 @@
/**
* The default browser version.
*/
- private BrowserVersion defaultBrowserVersion = BrowserVersion.FIREFOX_24;
+ private BrowserVersion defaultBrowserVersion = BrowserVersion.FIREFOX_38;
/**
* Should we ignore failing status codes?
@@ -222,7 +222,7 @@
ExpectedJavascriptConfirmException,
ExpectedJavascriptPromptException {
if (wc != null) {
- wc.closeAllWindows();
+ wc.close();
wc = null;
}
form = null; // reset current form
@@ -841,7 +841,7 @@
*/
BrowserVersion bv;
if (testContext.getUserAgent() != null) {
- bv = BrowserVersion.FIREFOX_24;
+ bv = BrowserVersion.FIREFOX_38;
bv.setUserAgent(testContext.getUserAgent());
} else {
bv = defaultBrowserVersion; // use default (which includes a full UserAgent string)
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2014-03-17 23:23:25 UTC (rev 976)
+++ trunk/pom.xml 2015-07-13 15:52:13 UTC (rev 977)
@@ -20,7 +20,7 @@
</issueManagement>
<inceptionYear>2002</inceptionYear>
<prerequisites>
- <maven>2.2.1</maven>
+ <maven>3.0</maven>
</prerequisites>
<modules>
<module>jwebunit-code-generator</module>
@@ -199,8 +199,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>1.7</source>
+ <target>1.7</target>
</configuration>
</plugin>
<plugin>
@@ -379,7 +379,7 @@
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
- <version>8.1.7.v20120910</version>
+ <version>9.2.11.v20150529</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2014-03-17 23:23:25 UTC (rev 976)
+++ trunk/src/changes/changes.xml 2015-07-13 15:52:13 UTC (rev 977)
@@ -30,6 +30,14 @@
</author>
</properties>
<body>
+ <release version="3.3" date="UNKNOWN" description="HtmlUnit 2.17, Java 7">
+ <action type="update" dev="henryju">
+ Updated to HtmlUnit 2.17.
+ </action>
+ <action type="update" dev="henryju">
+ Requires Java 7+.
+ </action>
+ </release>
<release version="3.2" date="March 17, 2014" description="HtmlUnit 2.14">
<action type="update" dev="henryju">
Updated to JUnit 4.11.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2015-07-13 16:24:07
|
Revision: 978
http://sourceforge.net/p/jwebunit/code/978
Author: henryju
Date: 2015-07-13 16:24:04 +0000 (Mon, 13 Jul 2015)
Log Message:
-----------
#134 WebTester.submit() does not find submit button
Modified Paths:
--------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java
trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html
trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/SingleNamedButtonForm.html
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java
===================================================================
--- trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java 2015-07-13 15:52:13 UTC (rev 977)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ButtonAssertionsTest.java 2015-07-13 16:24:04 UTC (rev 978)
@@ -34,9 +34,11 @@
@Test
public void testAssertButtonwithOneFormfound() {
beginAt("/pageWithOneForm.html");
+ assertSubmitButtonPresent();
assertButtonPresent("button1");
assertButtonPresent("buttonOutside");
setWorkingForm("form1");
+ assertSubmitButtonPresent();
assertButtonPresent("button1");
assertButtonPresent("buttonOutside");
assertButtonPresent("button1");
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 2015-07-13 15:52:13 UTC (rev 977)
+++ trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/FormSubmissionTest.java 2015-07-13 16:24:04 UTC (rev 978)
@@ -58,6 +58,10 @@
setTextField("color", "red");
submit();
assertTextPresent("color=[red]");
+ clickLink("return");
+ setTextField("color", "black");
+ submit("button2");
+ assertTextPresent("color=[black]");
}
@Test
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html 2015-07-13 15:52:13 UTC (rev 977)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/ButtonAssertionsTest/pageWithOneForm.html 2015-07-13 16:24:04 UTC (rev 978)
@@ -25,7 +25,7 @@
<html>
<body>
<form id="form1">
-<button id="button1">Testbutton</button>
+<button id="button1" type="submit">Testbutton</button>
</form>
<button id="buttonOutside">Outside</button>
<input type="button" value="Input button" />
Modified: trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/SingleNamedButtonForm.html
===================================================================
--- trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/SingleNamedButtonForm.html 2015-07-13 15:52:13 UTC (rev 977)
+++ trunk/jwebunit-commons-tests/src/main/resources/testcases/FormSubmissionTest/SingleNamedButtonForm.html 2015-07-13 16:24:04 UTC (rev 978)
@@ -28,6 +28,7 @@
<input type="submit" name="button" value="click me">
<input type="hidden" name="myReferer" value="FormSubmissionTest/SingleNamedButtonForm.html">
<input type="hidden" name="hidden" value="foo">
+ <button type="submit" name="button2">A Button</button>
</form>
</body>
</html>
\ No newline at end of file
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2015-07-13 15:52:13 UTC (rev 977)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2015-07-13 16:24:04 UTC (rev 978)
@@ -1239,9 +1239,11 @@
List<HtmlElement> btns = new LinkedList<HtmlElement>();
if (form != null) {
btns.addAll(getForm().getInputsByName(buttonName));
+ btns.addAll(getForm().getButtonsByName(buttonName));
} else {
for (HtmlForm f : getCurrentPage().getForms()) {
btns.addAll(f.getInputsByName(buttonName));
+ btns.addAll(f.getButtonsByName(buttonName));
}
}
for (HtmlElement o : btns) {
@@ -1276,9 +1278,11 @@
List<HtmlElement> btns = new LinkedList<HtmlElement>();
if (form != null) {
btns.addAll(getForm().getInputsByName(buttonName));
+ btns.addAll(getForm().getButtonsByName(buttonName));
} else {
for (HtmlForm f : getCurrentPage().getForms()) {
btns.addAll(f.getInputsByName(buttonName));
+ btns.addAll(f.getButtonsByName(buttonName));
}
}
for (HtmlElement o : btns) {
@@ -1314,9 +1318,11 @@
List<HtmlElement> btns = new LinkedList<HtmlElement>();
if (form != null) {
btns.addAll(getForm().getInputsByName(buttonName));
+ btns.addAll(getForm().getButtonsByName(buttonName));
} else {
for (HtmlForm f : getCurrentPage().getForms()) {
btns.addAll(f.getInputsByName(buttonName));
+ btns.addAll(f.getButtonsByName(buttonName));
}
}
for (HtmlElement o : btns) {
@@ -1351,16 +1357,54 @@
}
return null;
}
+
+ private HtmlElement getSubmitButton() {
+ List<HtmlElement> btns = new LinkedList<HtmlElement>();
+ if (form != null) {
+ btns.addAll(getForm().getElementsByAttribute("input", "type", "submit"));
+ btns.addAll(getForm().getElementsByAttribute("input", "type", "image"));
+ btns.addAll(getForm().getElementsByAttribute("button", "type", "submit"));
+ } else {
+ for (HtmlForm f : getCurrentPage().getForms()) {
+ btns.addAll(f.getElementsByAttribute("input", "type", "submit"));
+ btns.addAll(f.getElementsByAttribute("input", "type", "image"));
+ btns.addAll(f.getElementsByAttribute("button", "type", "submit"));
+ }
+ }
+ for (HtmlElement o : btns) {
+ if (o instanceof HtmlSubmitInput) {
+ HtmlSubmitInput btn = (HtmlSubmitInput) o;
+ if (form == null) {
+ form = btn.getEnclosingFormOrDie();
+ }
+ return btn;
+ }
+ if (o instanceof HtmlImageInput) {
+ HtmlImageInput btn = (HtmlImageInput) o;
+ if (form == null) {
+ form = btn.getEnclosingFormOrDie();
+ }
+ return btn;
+ }
+ if (o instanceof HtmlButton) {
+ HtmlButton btn = (HtmlButton) o;
+ if (btn.getTypeAttribute().equals("submit")) {
+ if (form == null) {
+ form = btn.getEnclosingFormOrDie();
+ }
+ return btn;
+ }
+ }
+ }
+ return null;
+ }
/**
* {@inheritDoc}
*/
@Override
public boolean hasSubmitButton() {
- final HtmlForm htmlForm = getForm();
- List<?> l = htmlForm.getByXPath("//input[@type='submit' or @type='image']");
- List<?> l2 = htmlForm.getByXPath("//button[@type='submit']");
- return (l.size() > 0 || l2.size() > 0);
+ return getSubmitButton() != null;
}
/**
@@ -1589,36 +1633,20 @@
*/
@Override
public void submit() {
+ HtmlElement btn = getSubmitButton();
+ if (btn == null) {
+ throw new RuntimeException("No submit button found in current form.");
+ }
try {
- Object[] inpt = getForm().getHtmlElementsByTagName("input")
- .toArray();
- for (int i = 0; i < inpt.length; i++) {
- if (inpt[i] instanceof HtmlSubmitInput) {
- ((HtmlSubmitInput) inpt[i]).click();
- return;
- }
- if (inpt[i] instanceof HtmlImageInput) {
- ((HtmlImageInput) inpt[i]).click();
- return;
- }
- if (inpt[i] instanceof HtmlButton
- && ((HtmlButton) inpt[i]).getTypeAttribute().equals(
- "submit")) {
- ((HtmlButton) inpt[i]).click();
- return;
- }
- }
-
+ btn.click();
} catch (FailingHttpStatusCodeException e) {
throw new TestingEngineResponseException(
- e.getStatusCode(), e);
+ e.getStatusCode(), e);
} catch (IOException e) {
throw new RuntimeException(
- "HtmlUnit Error submitting form using default submit button, "
- + "check that form has single submit button, otherwise use submit(name): \n",
- e);
+ "HtmlUnit Error submitting form using default submit button, "
+ + "check that form has single submit button, otherwise use submit(name): \n", e);
}
- throw new RuntimeException("No submit button found in current form.");
}
/**
@@ -1629,37 +1657,19 @@
*/
@Override
public void submit(String buttonName) {
- List<HtmlElement> l = new LinkedList<HtmlElement>();
- l.addAll(getForm().getInputsByName(buttonName));
- l.addAll(getForm().getButtonsByName(buttonName));
+ HtmlElement btn = getSubmitButton(buttonName);
+ if (btn == null) {
+ throw new RuntimeException("No submit button found in current form.");
+ }
try {
- for (HtmlElement o : l) {
- if (o instanceof HtmlSubmitInput) {
- HtmlSubmitInput inpt = (HtmlSubmitInput) o;
- inpt.click();
- return;
- }
- if (o instanceof HtmlImageInput) {
- HtmlImageInput inpt = (HtmlImageInput) o;
- inpt.click();
- return;
- }
- if (o instanceof HtmlButton) {
- HtmlButton inpt = (HtmlButton) o;
- if (inpt.getTypeAttribute().equals("submit")) {
- inpt.click();
- return;
- }
- }
- }
+ btn.click();
} catch (FailingHttpStatusCodeException e) {
throw new TestingEngineResponseException(
- e.getStatusCode(), e);
+ e.getStatusCode(), e);
} catch (IOException e) {
throw new RuntimeException(
- "HtmlUnit Error submitting form using default submit button", e);
+ "HtmlUnit Error submitting form using default submit button", e);
}
- throw new RuntimeException("No submit button found in current form.");
}
/**
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2015-07-13 15:52:13 UTC (rev 977)
+++ trunk/src/changes/changes.xml 2015-07-13 16:24:04 UTC (rev 978)
@@ -31,6 +31,9 @@
</properties>
<body>
<release version="3.3" date="UNKNOWN" description="HtmlUnit 2.17, Java 7">
+ <action type="fix" dev="henryju" issue="134" due-to="Joerg Troester">
+ WebTester.submit() does not find submit button.
+ </action>
<action type="update" dev="henryju">
Updated to HtmlUnit 2.17.
</action>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2015-07-13 16:33:43
|
Revision: 980
http://sourceforge.net/p/jwebunit/code/980
Author: henryju
Date: 2015-07-13 16:33:41 +0000 (Mon, 13 Jul 2015)
Log Message:
-----------
#136 Setting User-Agent not work when multiple WebTesters with different User-Agent
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2015-07-13 16:29:01 UTC (rev 979)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2015-07-13 16:33:41 UTC (rev 980)
@@ -841,7 +841,7 @@
*/
BrowserVersion bv;
if (testContext.getUserAgent() != null) {
- bv = BrowserVersion.FIREFOX_38;
+ bv = BrowserVersion.FIREFOX_38.clone();
bv.setUserAgent(testContext.getUserAgent());
} else {
bv = defaultBrowserVersion; // use default (which includes a full UserAgent string)
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2015-07-13 16:29:01 UTC (rev 979)
+++ trunk/src/changes/changes.xml 2015-07-13 16:33:41 UTC (rev 980)
@@ -31,6 +31,9 @@
</properties>
<body>
<release version="3.3" date="UNKNOWN" description="HtmlUnit 2.17, Java 7">
+ <action type="fix" dev="henryju" issue="136" due-to="Randy Chang">
+ Setting User-Agent not work when multiple WebTesters with different User-Agent.
+ </action>
<action type="fix" dev="henryju" issue="129,134" due-to="Ivo Maixner, Joerg Troester">
WebTester.submit() does not find submit button.
</action>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2015-07-13 16:42:47
|
Revision: 981
http://sourceforge.net/p/jwebunit/code/981
Author: henryju
Date: 2015-07-13 16:42:44 +0000 (Mon, 13 Jul 2015)
Log Message:
-----------
#135 Exception from setWorkingForm should indicate the requested form details
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java
===================================================================
--- trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2015-07-13 16:33:41 UTC (rev 980)
+++ trunk/jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java 2015-07-13 16:42:44 UTC (rev 981)
@@ -399,7 +399,11 @@
*/
@Override
public void setWorkingForm(int index) {
- setWorkingForm(getForm(index));
+ HtmlForm newForm = getForm(index);
+ if (newForm == null) {
+ throw new UnableToSetFormException("No form found in current page with index " + index);
+ }
+ setWorkingForm(newForm);
}
/**
@@ -407,7 +411,11 @@
*/
@Override
public void setWorkingForm(String nameOrId, int index) {
- setWorkingForm(getForm(nameOrId, index));
+ HtmlForm newForm = getForm(nameOrId, index);
+ if (newForm == null) {
+ throw new UnableToSetFormException("No form found in current page with name or id [" + nameOrId + "] and index " + index);
+ }
+ setWorkingForm(newForm);
}
/**
@@ -1183,9 +1191,6 @@
}
private void setWorkingForm(HtmlForm newForm) {
- if (newForm == null) {
- throw new UnableToSetFormException("Attempted to set form to null.");
- }
form = newForm;
}
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2015-07-13 16:33:41 UTC (rev 980)
+++ trunk/src/changes/changes.xml 2015-07-13 16:42:44 UTC (rev 981)
@@ -31,6 +31,9 @@
</properties>
<body>
<release version="3.3" date="UNKNOWN" description="HtmlUnit 2.17, Java 7">
+ <action type="fix" dev="henryju" issue="135" due-to="Joseph Walton">
+ Exception from setWorkingForm should indicate the requested form details.
+ </action>
<action type="fix" dev="henryju" issue="136" due-to="Randy Chang">
Setting User-Agent not work when multiple WebTesters with different User-Agent.
</action>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <he...@us...> - 2015-07-29 09:18:55
|
Revision: 982
http://sourceforge.net/p/jwebunit/code/982
Author: henryju
Date: 2015-07-29 09:18:53 +0000 (Wed, 29 Jul 2015)
Log Message:
-----------
Update to HTMLUnit 2.18
Modified Paths:
--------------
trunk/jwebunit-htmlunit-plugin/pom.xml
trunk/src/changes/changes.xml
Modified: trunk/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/pom.xml 2015-07-13 16:42:44 UTC (rev 981)
+++ trunk/jwebunit-htmlunit-plugin/pom.xml 2015-07-29 09:18:53 UTC (rev 982)
@@ -23,7 +23,7 @@
<dependency>
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
- <version>2.17</version>
+ <version>2.18</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2015-07-13 16:42:44 UTC (rev 981)
+++ trunk/src/changes/changes.xml 2015-07-29 09:18:53 UTC (rev 982)
@@ -30,7 +30,7 @@
</author>
</properties>
<body>
- <release version="3.3" date="UNKNOWN" description="HtmlUnit 2.17, Java 7">
+ <release version="3.3" date="UNKNOWN" description="HtmlUnit 2.18, Java 7">
<action type="fix" dev="henryju" issue="135" due-to="Joseph Walton">
Exception from setWorkingForm should indicate the requested form details.
</action>
@@ -41,7 +41,7 @@
WebTester.submit() does not find submit button.
</action>
<action type="update" dev="henryju">
- Updated to HtmlUnit 2.17.
+ Updated to HtmlUnit 2.18.
</action>
<action type="update" dev="henryju">
Requires Java 7+.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|