Skip to content
This repository was archived by the owner on Apr 7, 2022. It is now read-only.

Commit 1e72e98

Browse files
committed
#135 Exception from setWorkingForm should indicate the requested form details
1 parent aa64e4f commit 1e72e98

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

jwebunit-htmlunit-plugin/src/main/java/net/sourceforge/jwebunit/htmlunit/HtmlUnitTestingEngineImpl.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,15 +399,23 @@ public void gotoFrame(String frameNameOrId) {
399399
*/
400400
@Override
401401
public void setWorkingForm(int index) {
402-
setWorkingForm(getForm(index));
402+
HtmlForm newForm = getForm(index);
403+
if (newForm == null) {
404+
throw new UnableToSetFormException("No form found in current page with index " + index);
405+
}
406+
setWorkingForm(newForm);
403407
}
404408

405409
/**
406410
* {@inheritDoc}
407411
*/
408412
@Override
409413
public void setWorkingForm(String nameOrId, int index) {
410-
setWorkingForm(getForm(nameOrId, index));
414+
HtmlForm newForm = getForm(nameOrId, index);
415+
if (newForm == null) {
416+
throw new UnableToSetFormException("No form found in current page with name or id [" + nameOrId + "] and index " + index);
417+
}
418+
setWorkingForm(newForm);
411419
}
412420

413421
/**
@@ -1183,9 +1191,6 @@ protected HtmlPage getCurrentPage() {
11831191
}
11841192

11851193
private void setWorkingForm(HtmlForm newForm) {
1186-
if (newForm == null) {
1187-
throw new UnableToSetFormException("Attempted to set form to null.");
1188-
}
11891194
form = newForm;
11901195
}
11911196

src/changes/changes.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
</properties>
3232
<body>
3333
<release version="3.3" date="UNKNOWN" description="HtmlUnit 2.17, Java 7">
34+
<action type="fix" dev="henryju" issue="135" due-to="Joseph Walton">
35+
Exception from setWorkingForm should indicate the requested form details.
36+
</action>
3437
<action type="fix" dev="henryju" issue="136" due-to="Randy Chang">
3538
Setting User-Agent not work when multiple WebTesters with different User-Agent.
3639
</action>

0 commit comments

Comments
 (0)