/** * Sets the value of a parameter in this form. * @param name - the name of the parameter * @param value - the value of the parameter **/ public void setParameter( String name, String value ) { setParameter( name, new String[] { value } ); }
/** * Removes a parameter name from this collection. **/ public void removeParameter( String name ) { setParameter( name, NO_VALUES ); }
/** * Sets the value of a parameter in this form. * @param name - the name of the parameter * @param value - the value of the parameter **/ public void setParameter( String name, String value ) { setParameter( name, new String[] { value } ); }
public void update(WebForm form) { form.setParameter(field.value, value); } });
public void update(WebForm form) { form.setParameter("knob", state); } });
/** * Removes a parameter name from this collection. **/ public void removeParameter( String name ) { setParameter( name, NO_VALUES ); }
/** * Removes a parameter name from this collection. **/ public void removeParameter( String name ) { setParameter( name, NO_VALUES ); }
/** * Sets the value of a parameter in this form. * @param name - the name of the parameter * @param value - the value of the parameter **/ public void setParameter( String name, String value ) { setParameter( name, new String[] { value } ); }
public void act(WebForm form) throws IOException { form.setParameter("type","link"); form.setParameter("url",link.toString()); } });
public void update(WebForm form) { form.setParameter("knob","resolve"); form.setParameter("resolution",resolution.name()); } });
public void update(WebForm form) { form.setParameter("knob","duplicate"); form.setParameter("dup_id",String.valueOf(issue.getId())); } });
/** * Sets the single value of a file upload parameter in this form. * A more convenient way to do this than using {@link #setParameter(String,com.meterware.httpunit.protocol.UploadFileSpec[])} * @since 1.6 */ public void setParameter( String name, File file ) { setParameter( name, new UploadFileSpec[] { new UploadFileSpec( file ) } ); }
/** * Sets the single value of a file upload parameter in this form. * A more convenient way to do this than using {@link #setParameter(String,com.meterware.httpunit.protocol.UploadFileSpec[])} * @since 1.6 */ public void setParameter( String name, File file ) { setParameter( name, new UploadFileSpec[] { new UploadFileSpec( file ) } ); }
public void update(WebForm form) { final String field = "status_whiteboard"; String value = form.getParameterValue(field); form.setParameter(field, (value == null ? words : value + " " + words)); } });
public void act(WebForm form) throws IOException { if (form.hasParameterNamed("type")) form.setParameter("type", "file"); form.setParameter("file",new UploadFileSpec[]{ new UploadFileSpec(fileName,data,contentType)}); // this version somehow posts the full file name to the server, which often confuses it. // new UploadFileSpec(fileToUpload)}); } });
public void act(WebForm form) throws IOException { if(!fileToUpload.exists() || !fileToUpload.isFile()) throw new IOException(fileToUpload+" is not a file"); if (form.hasParameterNamed("type")) form.setParameter("type", "file"); form.setParameter("file",new UploadFileSpec[]{ new UploadFileSpec(fileToUpload.getName(),new FileInputStream(fileToUpload),guessContentType(fileToUpload))}); // this version somehow posts the full file name to the server, which often confuses it. // new UploadFileSpec(fileToUpload)}); } });
WebConversation conversation = new WebConversation(); WebRequest request = new GetMethodWebRequest("http://your-site-to-test.com/path-to-your-upload-form"); WebResponse response = conversation.getResponse(request); WebForm form = response.getFormWithName("stockImageUpload"); UploadFileSpec uploadFileSpec = new UploadFileSpec("test.jpg",new File("C:/test.jpg"), "image/jpeg"); form.setParameter("propertyImage", new UploadFileSpec[] {uploadFileSpec});
protected Object scrape() throws IOException, SAXException, ProcessingException { WebResponse r = goTo( folder.project._getURL()+"/servlets/ProjectDocumentEdit?documentID="+id); WebForm f = Util.getFormWithAction(r, "ProjectDocumentEdit?action=Edit%20file&documentID=" + id); f.setParameter("folder",String.valueOf(newFolder.getId())); checkError(f.submit()); folder.reset(); newFolder.reset(); return null; } }.run();
protected String scrape() throws IOException, SAXException, ProcessingException { WebResponse response = goTo(_getURL()+"/servlets/ProjectEdit"); WebForm form = Util.getFormWithAction(response,"ProjectEdit"); String old = form.getParameterValue("status"); form.setParameter("status",msg); checkError(form.submit()); return old; } }.run();
protected Object scrape() throws IOException, SAXException, ProcessingException { String url = project._getURL() + "/servlets/ProjectNewsApproval"; WebResponse response = goTo(url); WebForm form = Util.getFormWithAction(response, url); if(form==null) throw new ProcessingException("missing form"); form.setParameter("operation "+id, action); checkError(form.submit()); return null; } }.run();