本文整理汇总了Java中com.meterware.httpunit.WebForm.getParameterNames方法的典型用法代码示例。如果您正苦于以下问题:Java WebForm.getParameterNames方法的具体用法?Java WebForm.getParameterNames怎么用?Java WebForm.getParameterNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.meterware.httpunit.WebForm
的用法示例。
在下文中一共展示了WebForm.getParameterNames方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}
示例2: addUserToSend
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
/**
* @param notifsPage
* @param firstName
* @param lastName
* @throws SAXException
*/
public static void addUserToSend(WebResponse notifsPage, String firstName, String lastName) throws SAXException {
WebForm mainForm;
String[] paramNames;
String uuid;
User user;
mainForm = notifsPage.getFormWithName("mainform");
paramNames = mainForm.getParameterNames();
String newUserCheck = null;
for (int i = 0; i < paramNames.length; i++) {
if (paramNames[i].startsWith("add_user_")) {
newUserCheck = paramNames[i];
break;
}
}
uuid = newUserCheck.substring(newUserCheck.lastIndexOf("_")+1, newUserCheck.length());
BrokerFactory.getLoggingBroker().logDebug("Found uuid = "+uuid);
user = BrokerFactory.getUserMgmtBroker().getUserByUuid(uuid);
assertNotNull("Given uuid was not found in the system", user);
assertEquals("First name didn't match", user.getFirstName(), firstName);
assertEquals("Last name didn't match", user.getLastName(), lastName);
}
示例3: 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());
}
}
示例4: 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;
}
示例5: verifyValuesOnPopulatePage
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
protected void verifyValuesOnPopulatePage(WebForm inForm, List inIgnoreList) throws Exception {
System.out.println("\nEntered verifyValuesOnPopulatePage: ");
String[] theParameters = inForm.getParameterNames();
for (int i = 0; i < theParameters.length; i++) {
String theParameterName = theParameters[i];
System.out.println("ParameterName(Form): " + theParameterName + "\t ParameterValue: " + inForm.getParameterValue(theParameterName));
if(!inIgnoreList.contains(theParameterName) ){
if (!theParameterName.equals("method") && !theParameterName.equals("unprotected_method")) {
String theParameterValue = TestUtil.getMap().get(theParameterName).toString();
System.out.println("ParameterName(Map): " + theParameterName + "\t ParameterValue: " + theParameterValue);
if (!Constants.Dropdowns.OTHER_OPTION.equals(theParameterValue) && theParameterValue !=null) {
assertCurrentPageContains(theParameterValue);
}
}
}
}
System.out.println("Exited verifyValuesOnPopulatePage: \n");
}