本文整理汇总了Java中com.meterware.httpunit.WebResponse.getForms方法的典型用法代码示例。如果您正苦于以下问题:Java WebResponse.getForms方法的具体用法?Java WebResponse.getForms怎么用?Java WebResponse.getForms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.meterware.httpunit.WebResponse
的用法示例。
在下文中一共展示了WebResponse.getForms方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleActivity
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
private WebResponse handleActivity(WebResponse resp) throws SAXException, IOException, InterruptedException {
// MockLearner.log.debug(resp.getText());
WebResponse nextResp = null;
WebForm[] forms = resp.getForms();
if ((forms != null) && (forms.length > 0)) {
MockLearner.log.debug("There " + (forms.length == 1 ? "is " : "are ") + forms.length
+ (forms.length == 1 ? " form in the page " : " forms in the page"));
nextResp = handlePageWithForms(resp);
} else {
nextResp = handlePageWithoutForms(resp);
}
String asText = nextResp == null ? null : nextResp.getText();
boolean isActivityFinished = (asText != null) && (asText.contains(MockLearner.ACTIVITY_FINISHED_FLAG)
|| asText.contains(MockLearner.LESSON_FINISHED_FLAG)
|| asText.contains(MockLearner.LOAD_TOOL_ACTIVITY_FLAG));
return isActivityFinished ? nextResp : handleActivity(nextResp);
}
示例2: testTopicValueAttributes
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testTopicValueAttributes () throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/InvokeTag/testTopicValueAttributes.jsp");
WebForm form = resp.getForms()[0];
Node node = getLastElementChild(form.getDOMSubtree());
// The "1" is the objectId of the TM object passed as the value.
// Since we do not have access to the TM here, we must just do a
// hard coded check.
// NOTE: this value may change if the LTM parser changes.
checkAttribute(node, "value", "1");
checkCommonAttributes(node);
//Submit the form to check that no problems occur
form.submit();
// Check for the correct forward
assertEquals("Incorrect Result", webedTestApplication
+ "/test/defaultForward.html", wc.getCurrentPage().getURL().getPath());
}
示例3: testHiddenAttributes
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testHiddenAttributes () throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/FieldTag/testHiddenAttributes.jsp");
WebForm form = resp.getForms()[0];
// The field is rendered as the last item in the frames DOM
Node node = getLastElementChild(form.getDOMSubtree());
checkType(node, "input");
checkAttribute(node, "value", "VALUE");
checkAttribute(node, "type", "hidden");
checkCommonAttributes(node);
//Submit the form to check that no problems occur
form.submit();
// Check for the correct forward
assertEquals("Incorrect Result", webedTestApplication
+ "/test/defaultForward.html", wc.getCurrentPage().getURL().getPath());
}
示例4: testSubmitAttributes
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testSubmitAttributes () throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/ButtonTag/testSubmitAttributes.jsp");
WebForm form = resp.getForms()[0];
// The button is rendered as the last item in the frames DOM
Node button = getLastElementChild(form.getDOMSubtree());
checkAttribute(button, "type", "submit");
checkAttribute(button, "value", "BUTTON");
checkNameAttribute(button, "buttonTest");
checkCommonButtonAttributes(button);
//Submit the form to check that no problems occur
form.getButtons()[0].click();
// Check for the correct forward
assertEquals("Incorrect Result", webedTestApplication
+ "/test/defaultForward.html", wc.getCurrentPage().getURL().getPath());
}
示例5: testTextAreaAttributes
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testTextAreaAttributes () throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/FieldTag/testTextAreaAttributes.jsp");
WebForm form = resp.getForms()[0];
// The field is rendered as the last item in the frames DOM
Node node = getLastElementChild(form.getDOMSubtree());
checkType(node, "textarea");
checkAttribute(node, "cols", "50");
checkAttribute(node, "rows", "3");
checkCommonAttributes(node);
assertEquals("Missing value", "VALUE", node.getFirstChild().getNodeValue());
//Submit the form to check that no problems occur
form.submit();
// Check for the correct forward
assertEquals("Incorrect Result", webedTestApplication
+ "/test/defaultForward.html", wc.getCurrentPage().getURL().getPath());
}
示例6: testDropdownAttributesWithNone
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testDropdownAttributesWithNone () throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/ListTag/testDropdownAttributesWithNone.jsp");
WebForm form = resp.getForms()[0];
Node node = getLastElementChild(form.getDOMSubtree());
checkListAttributes(node, null, getKnownContents());
//Submit the form to check that no problems occur
form.submit();
// Check for the correct forward
assertEquals("Incorrect Result", webedTestApplication
+ "/test/defaultForward.html", wc.getCurrentPage().getURL().getPath());
}
示例7: testExclusiveEvaluateLTM
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testExclusiveEvaluateLTM() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/General/testExclusiveEvaluateLTM.jsp");
WebForm form = response.getForms()[0];
// Modify both fields
form.setParameter(response.getElementWithID("field").getName(), "passedExclusiveEvaluateLTM" );
//Submit the form
form.getButtons()[0].click();
// Check if the webed:field content was evaluated (as it should), even
// though it's action was excluded.
assertTrue("Response doesn not contain expected text "
+ "'passedExclusiveEvaluateLTM'", wc.getCurrentPage().getText()
.indexOf("passedExclusiveEvaluateLTM") >= 0);
}
示例8: testNoStateAttributes
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testNoStateAttributes () throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/CheckboxTag/testNoStateAttributes.jsp");
WebForm form = resp.getForms()[0];
// The checkbox is rendered as the last item in the frames DOM
Node checkbox = getLastElementChild(form.getDOMSubtree());
checkCommonAttributes(checkbox);
assertNull("Checked attribute found", checkbox.getAttributes().getNamedItem("checked"));
//Submit the form to check that no problems occur
form.submit();
// Check for the correct forward
assertEquals("Incorrect Result", webedTestApplication
+ "/test/defaultForward.html", wc.getCurrentPage().getURL().getPath());
}
示例9: testSubaction
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testSubaction() throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/CheckboxTag/testSubactionForward.jsp");
WebForm form = resp.getForms()[0];
form.getButtons()[0].click();
resp = wc.getResponse(webedTestLocation
+ "/test/CheckboxTag/testSubaction.jsp");
form = resp.getForms()[0];
form.getButtons()[0].click();
resp = wc.getCurrentPage();
assertTrue("Created topic with subaction of unchecked checkbox." ,
wc.getCurrentPage().getText().indexOf("testCheckboxSubactionTopic") < 0);
resp = wc.getResponse(webedTestLocation
+ "/test/CheckboxTag/testSubaction.jsp");
form = resp.getForms()[0];
Node checkbox = getLastElementChild(form.getDOMSubtree());
form.setCheckbox(checkbox.getAttributes().getNamedItem("name").getNodeValue(), true);
form.getButtons()[0].click();
resp = wc.getCurrentPage();
assertTrue("Failed to create topic with subaction of checked checkbox." ,
wc.getCurrentPage().getText().indexOf("testCheckboxSubactionTopic") >= 0);
}
示例10: handleToolWiki
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
private WebForm handleToolWiki(WebForm form, String action) throws IOException, SAXException {
// add one random page...
form.setAttribute("action", action + "?dispatch=addPage");
WebResponse nextResp = (WebResponse) new Call(wc, test, username + " adds Wiki page", fillFormArbitrarily(form))
.execute();
form = nextResp.getForms()[1];
// ...and mark the activity to be finished
form.setAttribute("action", action + "?dispatch=finishActivity");
return form;
}
示例11: fillForm
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
protected WebForm fillForm(WebResponse resp, int formIndex, Map<String, Object> params)
throws SAXException, IOException {
WebForm[] forms = resp.getForms();
if ((forms == null) || (forms.length <= formIndex)) {
MockUser.log.debug(resp.getText());
throw new TestHarnessException(username + " cannot find a form with index " + formIndex);
}
WebForm form = forms[formIndex];
if (params != null) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
form.setParameter(entry.getKey(), (String) entry.getValue());
} else if (value instanceof File) {
form.setParameter(entry.getKey(), (File) entry.getValue());
} else if (value instanceof String[]) {
form.setParameter(entry.getKey(), (String[]) entry.getValue());
} else if (value instanceof UploadFileSpec[]) {
form.setParameter(entry.getKey(), (UploadFileSpec[]) entry.getValue());
} else {
throw new TestHarnessException(
"Unsupported parameter value type:" + entry.getValue().getClass().getName());
}
}
}
return form;
}
示例12: logOn
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
private WebResponse logOn(WebConversation wc, String url, String user, String password)
throws Exception {
WebRequest req = new GetMethodWebRequest(WEB_ROOT + url);
WebResponse resp = wc.getResponse(req);
assertEquals("Got To Log On Page", "Log On", resp.getTitle());
WebForm form = resp.getForms()[0];
WebRequest request = form.getRequest();
request.setParameter("j_username", user);
request.setParameter("j_password", password);
return wc.getResponse(request);
}
示例13: testScrollingAttributesWithNone
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testScrollingAttributesWithNone () throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/ListTag/testScrollingAttributesWithNone.jsp");
WebForm form = resp.getForms()[0];
Node node = getLastElementChild(form.getDOMSubtree());
checkScrollingAttributes(node, null);
//Submit the form to check that no problems occur
form.submit();
// Check for the correct forward
assertEquals("Incorrect Result", webedTestApplication
+ "/test/defaultForward.html", wc.getCurrentPage().getURL().getPath());
}
示例14: testPassesParameters
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testPassesParameters() throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/General/testActionParameters.jsp");
WebForm form = resp.getForms()[0];
form.getButtons()[0].click();
resp = wc.getCurrentPage();
assertEquals("An error while checking passed parameters","SUCCESS", resp.getText());
}
示例15: testDefaultForward
import com.meterware.httpunit.WebResponse; //导入方法依赖的package包/类
public void testDefaultForward() throws Exception {
WebResponse resp = wc.getResponse(webedTestLocation
+ "/test/General/testDefaultForward.jsp");
WebForm form = resp.getForms()[0];
resp = form.submit();
assertEquals("Default Forward Failed", webedTestApplication
+ "/test/defaultForward.html", resp.getURL().getPath());
}