当前位置: 首页>>代码示例>>Java>>正文


Java WebForm类代码示例

本文整理汇总了Java中com.meterware.httpunit.WebForm的典型用法代码示例。如果您正苦于以下问题:Java WebForm类的具体用法?Java WebForm怎么用?Java WebForm使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


WebForm类属于com.meterware.httpunit包,在下文中一共展示了WebForm类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleActivity

import com.meterware.httpunit.WebForm; //导入依赖的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);
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:MockLearner.java

示例2: checkUrlForView

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
private void checkUrlForView(String view) throws IOException, SAXException
{
	WebResponse response;
	WebForm form = m_response.getFormWithID("SetDateAndTime");
	form.setParameter("view", view);
	response = form.submit();
	String url = response.getURL().toString();
	
	String expectedUrl; 
	StringBuffer tempUrl = new StringBuffer(m_testUtils.getUrlPmgraph() +"?start=" + m_startTime
	+ "&end=" + m_endTime + "&width=780&height=350&fromDate=");
	tempUrl.append(insertDate(m_startTime));
	tempUrl.append("&toDate=");
	tempUrl.append(insertDate(m_endTime));
	tempUrl.append("&fromTime="); 
	tempUrl.append(insertTime(m_startTime));
	tempUrl.append("&toTime=");
	tempUrl.append(insertTime(m_endTime));
	tempUrl.append("&resultLimit=5&view=" + view + 
			"&selectGroupIndex=Test&Go=Draw+Graph");
	expectedUrl = tempUrl.toString();
	assertEquals(expectedUrl, url);
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:24,代码来源:UrlBuilderTest.java

示例3: testDeleteAllSubnets

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
public void testDeleteAllSubnets() throws InstantiationException, IllegalAccessException, 
ClassNotFoundException, SQLException, IOException, SAXException
{
	TestUtils theTestUtils = new TestUtils();		
	WebResponse response = loadUrl (theTestUtils);
	WebForm configurationForm = response.getFormWithID("config");
	
	int numSubnets = Integer.parseInt(configurationForm.getParameterValue("numSubnets"));
	String aux = "?";
	for (int i = 1; i <= numSubnets; i++)
		aux += "delSubnet"+i+"=delSubnet"+i+"&";
	aux +="numSubnets="+numSubnets;			
	WebRequest request = new GetMethodWebRequest(theTestUtils.getUrlPmgraph() + "configure.jsp"+aux);
    response = m_conversation.getResponse(request);
	
	configurationForm = response.getFormWithID("config");
	int newNumSubnets = Integer.parseInt(configurationForm.getParameterValue("numSubnets"));
	assertEquals(numSubnets, newNumSubnets);		
    HTMLElement result = response.getElementWithID("unsuccessResult");
    String resultString = result.getNode().getFirstChild().getNextSibling().getFirstChild().getNodeValue();
    assertTrue(resultString.equals("You can't delete all the subnets"));
}
 
开发者ID:aptivate,项目名称:pmgraph,代码行数:23,代码来源:TestMultiSubnets.java

示例4: clickAll

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
/**
 * @param resp
 * @param i
 * @throws SAXException
 * @throws IOException
 */
private void clickAll(WebResponse resp, int i, int maxDepth) throws SAXException,
		IOException
{

	if (i > maxDepth) return;
	processLinks(resp,i+1,maxDepth);
	
	WebForm[] formst = resp.getForms();
	log.info("Found "+formst.length+" forms");
	for ( WebForm f : formst ) {
		log.info("Processing "+f.getMethod()+" "+f.getAction());
		if ( "post".equals(f.getMethod()) ) {
			WebResponse formResp = performAction(f);
			if ( formResp != null ) {
				processLinks(formResp,i+1,maxDepth);
			}
		}
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:26,代码来源:AnonPortalTest.java

示例5: performAction

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
/**
 * @param f
 * @throws SAXException 
 * @throws IOException 
 */
private WebResponse performAction(WebForm f) throws IOException, SAXException
{
	String action = f.getAction();
	
	if ( isLocal(action) ) {
		action = getLocalUrl(action);
		for( ActionHandler ah : actionHandlers ) {
			WebResponse resp = ah.post(wc,f,action);
			if ( resp !=  null ) {
				return resp;
			}
		}
	}
	return null;
	
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:22,代码来源:AnonPortalTest.java

示例6: testTextAttributes

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
public void testTextAttributes () throws Exception {
  
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/FieldTag/testTextAttributes.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, "class", "input");
  checkAttribute(node, "type", "text");
  checkAttribute(node, "maxlength", "75");
  checkAttribute(node, "size", "50");
  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());
  
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:24,代码来源:FieldTagTest.java

示例7: testHiddenAttributes

import com.meterware.httpunit.WebForm; //导入依赖的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());
  
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:21,代码来源:FieldTagTest.java

示例8: testPasswordAttributes

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
public void testPasswordAttributes () throws Exception {
  
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/FieldTag/testPasswordAttributes.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", "password");
  checkAttribute(node, "class", "input");
  checkAttribute(node, "maxlength", "75");
  checkAttribute(node, "size", "50");
  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());
  
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:24,代码来源:FieldTagTest.java

示例9: testTextAreaAttributes

import com.meterware.httpunit.WebForm; //导入依赖的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());
  
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:23,代码来源:FieldTagTest.java

示例10: testNoStateAttributes

import com.meterware.httpunit.WebForm; //导入依赖的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());
      
  }
 
开发者ID:ontopia,项目名称:ontopia,代码行数:19,代码来源:CheckboxTagTest.java

示例11: testStateCheckedAttributes

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
public void testStateCheckedAttributes () throws Exception {

  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/CheckboxTag/testStateCheckedAttributes.jsp");
  WebForm form = resp.getForms()[0];
  // The checkbox is rendered as the last item in the frames DOM
  Node checkbox = getLastElementChild(form.getDOMSubtree());
  
  checkAttribute(checkbox, "checked", "checked");
  checkCommonAttributes(checkbox);
  
  //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());
  
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:19,代码来源:CheckboxTagTest.java

示例12: testStateUnCheckedAttributes

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
public void testStateUnCheckedAttributes () throws Exception {
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/CheckboxTag/testStateUnCheckedAttributes.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());
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:17,代码来源:CheckboxTagTest.java

示例13: testSubaction

import com.meterware.httpunit.WebForm; //导入依赖的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);
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:26,代码来源:CheckboxTagTest.java

示例14: testTopicValueAttributes

import com.meterware.httpunit.WebForm; //导入依赖的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());
  
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:21,代码来源:InvokeTagTest.java

示例15: testStringValueAttributes

import com.meterware.httpunit.WebForm; //导入依赖的package包/类
public void testStringValueAttributes () throws Exception {

  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/InvokeTag/testStringValueAttributes.jsp");
  WebForm form = resp.getForms()[0];
  Node node = getLastElementChild(form.getDOMSubtree());
  
  checkAttribute(node, "value", "VALUE");
  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());

}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:18,代码来源:InvokeTagTest.java


注:本文中的com.meterware.httpunit.WebForm类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。