本文整理汇总了Java中com.meterware.httpunit.WebForm.setParameter方法的典型用法代码示例。如果您正苦于以下问题:Java WebForm.setParameter方法的具体用法?Java WebForm.setParameter怎么用?Java WebForm.setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.meterware.httpunit.WebForm
的用法示例。
在下文中一共展示了WebForm.setParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: testRunIfNoChangesFalse
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testRunIfNoChangesFalse() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/InvokeTag/testRunIfNoChangesFalse.jsp");
WebForm form = response.getForms()[0];
// With "runIfNoChanges=false" the action should only run if another
// action on the form have run.
// First time, no action fired
form.getButtons()[0].click();
assertEquals("Action should not have executed", "null", wc.getCurrentPage().getText());
// Refresh form
response = wc.getResponse(webedTestLocation
+ "/test/InvokeTag/testRunIfNoChangesFalse.jsp");
form = response.getForms()[0];
// Modify value, action should run
form.setParameter(response.getElementWithID("FLD").getName(),"NEW VALUE");
form.getButtons()[0].click();
assertEquals("Action should have executed", "SUCCESS", wc.getCurrentPage().getText());
}
示例3: testDoubleSubmit
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testDoubleSubmit() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/InvokeTag/testRunIfNoChangesFalse.jsp");
WebForm form = response.getForms()[0];
// Submit different modification second time
form.setParameter(response.getElementWithID("FLD").getName(),"NEW VALUE1");
form.getButtons()[0].click();
assertEquals("Action should have executed", "SUCCESS", wc.getCurrentPage().getText());
try {
// Submit different modification second time
form.setParameter(response.getElementWithID("FLD").getName(),"NEW VALUE2");
form.getButtons()[0].click();
fail("Could submit form twice");
} catch (Exception e) {
// ok
}
}
示例4: testPeakAction
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testPeakAction() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/General/testPeakAction.jsp");
WebForm form = response.getForms()[0];
// Set the value of the field which associated with one action,
// then click the button and execute a second action associated
// with it which peaks at the parameters sent to the action
// associated with the field.
String result = "NEW VALUE";
form.setParameter((response.getElementWithID("FLD").getName()),result);
Button button = form.getButtonWithID("BTN");
button.click();
assertEquals("The target value was not visable", result, wc.getCurrentPage().getText());
}
示例5: testValueChanged
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testValueChanged() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/General/testValueChanged.jsp");
WebForm form = response.getForms()[0];
// Click the button, no value has changed, so no action should
// be executed
form.getButtonWithID("BTN").click();
assertEquals("The action appears to have beed executed", "null", wc.getCurrentPage().getText());
// Refresh form
response = wc.getResponse(webedTestLocation
+ "/test/General/testValueChanged.jsp");
form = response.getForms()[0];
// Modify the value of the input field and click the
// button again. This time the action should run.
form.setParameter((response.getElementWithID("FLD").getName()),"MODIFIED");
form.getButtonWithID("BTN").click();
assertEquals("The action does not appear to have run", "MODIFIED", wc.getCurrentPage().getText());
}
示例6: testActionOrdering
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testActionOrdering() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/General/testActionOrdering.jsp");
WebForm form = response.getForms()[0];
// Modify all fields
form.setParameter(response.getElementWithID("O1").getName(), "VALUE1" );
form.setParameter(response.getElementWithID("O2").getName(), "VALUE2" );
//Submit the form
form.getButtons()[0].click();
// All actions should run, and the result string should be
// VALUE1-VALUE2
assertEquals("Incorrect responce text", "VALUE1-VALUE2", wc.getCurrentPage().getText());
}
示例7: testNotExclusive
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testNotExclusive() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/General/testNotExclusiveAction.jsp");
WebForm form = response.getForms()[0];
// Modify both fields
form.setParameter(response.getElementWithID("NET1").getName(), "NET1V" );
form.setParameter(response.getElementWithID("NET2").getName(), "NET2V");
//Submit the form
form.getButtons()[0].click();
// Since neither action is exclusive, the response text should contain
// both "NET1V" and "NET2V"
assertTrue("Response does not contain the expected text 'NET1V'", wc.getCurrentPage().getText().indexOf("NET1V") >= 0);
assertTrue("Response does not contain the expected text 'NET2V'", wc.getCurrentPage().getText().indexOf("NET2V") >= 0);
}
示例8: testExclusive
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public void testExclusive() throws Exception {
WebResponse response = wc.getResponse(webedTestLocation
+ "/test/General/testExclusiveAction.jsp");
WebForm form = response.getForms()[0];
// Modify both fields
form.setParameter(response.getElementWithID("ET").getName(), "ETV" );
form.setParameter(response.getElementWithID("AT").getName(), "ATV");
//Submit the form
form.getButtons()[0].click();
// If only the exclusive action has executed, then the response text
// could contain only "ETV". If both are executed, then the responce
// text would also contain "ETV"
assertTrue("Response does not contain the expected text 'ETV'", wc.getCurrentPage().getText().indexOf("ETV") >= 0);
assertFalse("Response contains the unexpected text 'ATV'", wc.getCurrentPage().getText().indexOf("ATV") >= 0);
}
示例9: testExclusiveEvaluateLTM
import com.meterware.httpunit.WebForm; //导入方法依赖的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);
}
示例10: getAccesToken
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
private String getAccesToken(
final String applicationKey,
final String username,
final String password) throws IOException {
try {
HttpUnitOptions.setScriptingEnabled(false);
WebConversation wc = new WebConversation();
WebResponse resp = wc.getResponse(String.format(OAUTH_GET_ACCESS_TOKEN_URL, applicationKey));
WebForm form = findLoginForm(resp.getForms());
form.setParameter("login", username);
form.setParameter("password", password);
resp = form.submit();
if(!resp.getURL().toString().contains("code=")) {
resp = resp.getLinkWith("Allow").click();
}
return resp.getURL().toString().split("code=")[1];
} catch (SAXException ex) {
throw new IOException(ex);
}
}
示例11: login
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public static WebResponse login (WebConversation wc, String username, String password) throws IOException, SAXException {
WebResponse loginResponse = wc.getResponse ("http://localhost:8080/notification/index.jsp");
WebForm loginForm = loginResponse.getForms()[0];
loginForm.setParameter("username", username);
loginForm.setParameter("password", password);
SubmitButton loginButton = (SubmitButton)loginForm.getSubmitButton("Submit");
WebResponse notifsPage = loginForm.submit(loginButton);
return notifsPage;
}
示例12: signUpPatient
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
/**
* Convenience method to drive a click through of the process of signing up a new patient.
* @param patientConfig the specification of the patient to create
* @return a User instance representing the new patient
* @throws SAXException if there is an error parsing a page in the click-though sequence.
* @throws IOException if there is an issue reading a page.
*/
public User signUpPatient(PatientConfig patientConfig) throws SAXException, IOException {
setLoggedInUser(patientConfig.getEmail(), false);
WebResponse landingPage = client.getResponse("http://localhost/");
WebResponse signupPage = landingPage.getLinkWith("I am a patient").click();
WebForm signupForm = signupPage.getForms()[0];
signupForm.setParameter("name", patientConfig.getName());
signupForm.setParameter("location", patientConfig.getAddress());
signupForm.submit();
observeRateLimit();
return getUser();
}
示例13: addGroup
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public static WebResponse addGroup(WebResponse page, String groupName, boolean escalation) throws IOException, SAXException {
BrokerFactory.getLoggingBroker().logInfo("Adding a new group "+groupName);
WebResponse newPage = Actions.switchToPage(page, "Settings");
newPage = Actions.closeTab(newPage, "personalSettings");
newPage = Actions.openTab(newPage, "groupSettings");
Actions.checkPage(newPage);
newPage = Actions.openTab(newPage, "addGroup");
WebForm form = Actions.getMainForm(newPage);
form.setParameter("group_name", groupName);
form.setParameter("group_description", groupName+" automatically added by test script");
form.setParameter("group_type", escalation?"escalation":"broadcast");
newPage = Actions.clickSubmitButton(form, "action_group_save");
return newPage;
}
示例14: testSearchPage
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
/** This method tests the search Page. It also submits a query for cats and
* verifies that the result has at least two items */
private void testSearchPage(WebConversation wc, WebResponse resp) throws Exception {
// Test the search page
WebLink wl = resp.getLinkWith("Search");
wl.click();
resp = wc.getCurrentPage();
// check if the search returns more than one result for "cat
WebForm form = resp.getForms()[0];
assertEquals("on", form.getParameterValue("searchForm:searchTags"));
String searchText = "cat";
form.setParameter("searchForm:searchString", searchText);
form.submit();
resp = wc.getCurrentPage();
WebTable resultTable = resp.getTableStartingWithPrefix("Map");
assertTrue(resultTable.getRowCount() > 2);
}
示例15: addEmail
import com.meterware.httpunit.WebForm; //导入方法依赖的package包/类
public static WebResponse addEmail (WebResponse page, String address) throws SAXException, IOException {
BrokerFactory.getLoggingBroker().logInfo("Adding new email address "+address);
WebResponse settingsPage = Actions.switchToPage(page, "Settings");
Actions.checkPage(settingsPage);
WebForm mainForm = Actions.getMainForm(settingsPage);
settingsPage = Actions.openTab(settingsPage, "deviceSettings");
mainForm = settingsPage.getFormWithName("mainform");
// Open add a new email tab
settingsPage = Actions.openTab (settingsPage, "addNewEmail");
mainForm = settingsPage.getFormWithName("mainform");
mainForm.setParameter("Address_devicesetting", address);
settingsPage = Actions.clickSubmitButton(settingsPage, "action_device_save");
mainForm = settingsPage.getFormWithName("mainform");
settingsPage = Actions.closeTab (settingsPage, "addNewEmail");
return settingsPage;
}