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


Java WebForm.getParameterValue方法代码示例

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


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

示例1: verifyValuesOnPage

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
protected void verifyValuesOnPage(WebForm inForm, List inIgnoreList) throws Exception {
	
	System.out.println("\nEntered verifyValuesOnPage(): ");

    String[] theParameters = inForm.getParameterNames();
    System.out.println("The number of parameters from the form: " + theParameters.length);
    
    for (int i = 0; i < theParameters.length; i++) {       	

        String theParameterName = theParameters[i];
        
        if(!inIgnoreList.contains(theParameterName)){

        	if (!theParameterName.equals("method") && !theParameterName.equals("unprotected_method")) {
        		String theParameterValue = inForm.getParameterValue(theParameterName);
        		
        		if (!Constants.Dropdowns.OTHER_OPTION.equals(theParameterValue) && theParameterValue !=null) {
            		System.out.println("Set:  " + theParameterName + "  To: " + theParameterValue);            			
        			assertCurrentPageContains(theParameterValue);
        		}
        	}
        }
    }
	System.out.println("Exited verifyValuesOnPage(): \n");        
}
 
开发者ID:NCIP,项目名称:camod,代码行数:26,代码来源:BaseHttpTest.java

示例2: toggleTab

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public static WebResponse toggleTab(WebResponse page, String tabName, boolean open) 
throws IOException, SAXException {
	WebResponse settingsPage = null;
	WebForm mainForm = Actions.getMainForm(page);
	assertNotNull("Could not find main form", mainForm);
	assertNotNull("The name of the tab to toggle was not supplied", tabName);
	String tabParam = mainForm.getParameterValue("opened."+tabName);
	assertNotNull ("Could not find tab, "+tabName+" to toggle", tabParam);
	if (tabParam.equals(open?"false":"true")) {
		BrokerFactory.getLoggingBroker().logDebug("The "+tabName+" tab is "+(open?"closed":"open")+", so we're "+(open?"opening":"closing")+" it");
		// Open devices tab
		settingsPage = clickSubmitButton(page, "action_toggle_collapseable."+tabName);
	}
	if (settingsPage == null) return page;
	return settingsPage;
}
 
开发者ID:davidrudder23,项目名称:OpenNotification,代码行数:17,代码来源:Actions.java

示例3: testTrimAttributeTrue

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testTrimAttributeTrue () throws Exception {
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/FieldTag/testTrimAttributeTrue.jsp");
  String original = wc.getResponse(webedTestLocation
      + "/test/FieldTag/value.txt").getText();

  WebForm form = resp.getForms()[0];
  String value = form.getParameterValue(resp.getElementWithID("FLD").getName());

  // Trimming should be carried out
  assertFalse("No trimming occurred", original.equals(value));
  assertEquals("Incorrect Trimming", original.trim(), value);
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:14,代码来源:FieldTagTest.java

示例4: testTrimAttributeFalse

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testTrimAttributeFalse () throws Exception {
  
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/FieldTag/testTrimAttributeFalse.jsp");
  String original = wc.getResponse(webedTestLocation
      + "/test/FieldTag/value.txt").getText();

  HTMLElement field = resp.getElementWithID("FLD");
  WebForm form = resp.getForms()[0];
  String value = form.getParameterValue(field.getName());

  // Trimming should not be carried out
  assertEquals("Trimming occurred", original, value);

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

示例5: getFieldValue

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
/**
 * Check the contents of a given input field.
 * @param fieldID The ID of the field.
 * @throws SAXException
 */
protected String getFieldValue(String fieldID, WebResponse response)
    throws SAXException {
  HTMLElement field = response.getElementWithID(fieldID);
  assertNotNull(field);
  WebForm forms[] = response.getForms();
  assertTrue(forms.length > 0);
  WebForm form = forms[1];
  return form.getParameterValue(field.getName());
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:15,代码来源:FieldTagTest.java

示例6: testNoTrimAttribute

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testNoTrimAttribute () throws Exception {
  
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/FieldTag/testNoTrimAttribute.jsp");
  String original = wc.getResponse(webedTestLocation
      + "/test/FieldTag/value.txt").getText();

  WebForm form = resp.getForms()[0];
  String value = form.getParameterValue(resp.getElementWithID("FLD").getName());

  // By default trimming should be carried out
  assertFalse("No trimming occurred", original.equals(value));
  assertEquals("Incorrect Trimming", original.trim(), value);
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:15,代码来源:FieldTagTest.java

示例7: testFormUnregister

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testFormUnregister() throws Exception {
  WebResponse resp = wc.getResponse(webedTestLocation
      + "/test/General/testFormUnregister.jsp");
  WebForm form = resp.getForms()[0];
  Button button = form.getButtonWithID("testFormUnregister");
  
  String requestId = form.getParameterValue(Constants.RP_REQUEST_ID);
  wc.getResponse(webedTestLocation + "/unregister?requestid=" + requestId);
  
  try {
    button.click();
    fail("Failed to unregister form action data.");
  } catch (HttpInternalErrorException e) {
  }
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:16,代码来源:GeneralActionTest.java

示例8: checkField

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
/**
 * Check the contents of a given input field against a control value.
 * @param fieldID The ID of the field to control.
 * @param controlValue The value to check the field contents against.
 * @throws SAXException
 */
protected void checkField(String fieldID, String controlValue)
    throws SAXException {
  HTMLElement field = resp.getElementWithID(fieldID);
  assertNotNull(field);
  WebForm[] forms = resp.getForms();
  assertTrue("more than 0 forms", forms.length > 0);
  WebForm form0 = forms[0];
  String value = form0.getParameterValue(field.getName());
  assertEquals(fieldID, controlValue, value);
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:17,代码来源:AccessctlTest.java

示例9: generatePageTemplate

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
/**
	*  Generates prototype XML fragment baed on the current response and the specified form.
	*  Use to generate XML for a form to avoid having to type it in by hand
	*  Hint: if possible, try to specify a form with existing data rather than a blank form.
	*
	*@param  form  Name of form Element
	*@since
	*/
public void generatePageTemplate() throws NoResponseToProcess {
	if (lastResponse == null)
		throw new NoResponseToProcess();
	try {
		System.err.println("<definePage url=\"" + lastResponse.getURL() + "\" name=\"" + lastResponse.getTitle() + "\">");
		WebForm[] forms = lastResponse.getForms();
		for (int f = 0; f < forms.length; f++) {
			WebForm form = forms[f];
			System.err.println("\t<form name=\"" + form.getName() + "\" method=\"" + form.getMethod() + "\" action=\"" + form.getAction() + "\" >");
			String[] names = form.getParameterNames();
			for (int i = 0; i < names.length; i++) {
				form.getParameterValue(names[i]);
				System.err.println("\t\t<input name=\"" + names[i] + "\" type=\"\" value=\"" + form.getParameterValue(names[i]) + "\" />");
			}
			System.err.println("\t</form>");
		}
		WebLink[] links = lastResponse.getLinks();
		for (int f = 0; f < links.length; f++) {
			WebLink link = links[f];
			System.err.print("\t<link");
			System.err.print(" id=\"" + link.getID() + "\" ");
			System.err.print(" name=\"" + link.getName() + "\" ");
			System.err.print(" target=\"" + link.getTarget() + "\" ");
			System.err.print(" href=\"" + link.getURLString() + "\" ");
			System.err.println("/>");
		}
		System.err.println("</definePage>");
	}
	catch (SAXException e) {
		fail(e.toString());
	}
}
 
开发者ID:Amsoft-Systems,项目名称:xmltestsuiteR12,代码行数:41,代码来源:HttpResource.java

示例10: fillFormArbitrarily

import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
private WebForm fillFormArbitrarily(WebForm form) throws IOException, SAXException {
String[] params = form.getParameterNames();
if (params != null) {
    for (String param : params) {
	if (!form.isDisabledParameter(param) && !form.isHiddenParameter(param)
		&& !form.isReadOnlyParameter(param)) {
	    if (form.isTextParameter(param)) {
		String text = MockLearner.composeArbitraryText();
		form.setParameter(param, text);
		MockLearner.log.debug(username + " input " + text + " for form field " + param);

	    } else if (form.isFileParameter(param)) {
		File file = MockLearner.selectArbitraryFile(((LearnerTest) test).getFilesToUpload());
		form.setParameter(param, file);
		MockLearner.log
			.debug(username + " uploaded file " + file.getName() + " for form field " + param);
	    } else if (form.isMultiValuedParameter(param)) {
		String minValuesParam = form.getParameterValue(MockLearner.VOTE_MIN_NOMINATION_PARAM);
		String maxValuesParam = form.getParameterValue(MockLearner.VOTE_MAX_NOMINATION_PARAM);
		Integer minValues = minValuesParam == null ? null : Integer.parseInt(minValuesParam);
		Integer maxValues = maxValuesParam == null ? null : Integer.parseInt(maxValuesParam);

		String[] values = MockLearner.chooseArbitraryValues(form.getOptionValues(param), true,
			minValues, maxValues);
		form.setParameter(param, values);
		MockLearner.log.debug(username + " set " + values.length + " values for form field " + param
			+ ": " + Arrays.toString(values));
	    } else {
		MockLearner.log.debug(
			param + " may be a radio button. Current value is " + form.getParameterValue(param));
		if (form.getParameterValue(param) == null) {
		    String[] candidateValues = form.getOptionValues(param);
		    if ((candidateValues != null) && (candidateValues.length > 0)) {
			String value = candidateValues[TestUtil.generateRandomNumber(candidateValues.length)];
			MockLearner.log.debug(username + " set " + value + " for form field " + param);
			form.setParameter(param, value);
		    }
		}
	    }
	} else {
	    MockLearner.log.debug("Disabled or hidden or readonly parameter " + param + " with value "
		    + form.getParameterValue(param));
	}
    }
}

Map<String, List<Button>> buttonGroups = MockLearner.groupButtonsByName(form.getButtons(),
	FormControl.RADIO_BUTTON_TYPE);
for (Map.Entry<String, List<Button>> entry : buttonGroups.entrySet()) {
    entry.getValue().get(TestUtil.generateRandomNumber(entry.getValue().size())).click();
    MockLearner.log.debug(username + " clicked a radio button " + entry.getKey());
}
return form;
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:55,代码来源:MockLearner.java


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