4 messages in com.canoo.lists.webtestRE: [Webtest] File upload| From | Sent On | Attachments |
|---|---|---|
| skel...@jpmorgan.com | 16 Oct 2002 04:28 | |
| EPu...@upstate.com | 16 Oct 2002 04:36 | |
| skel...@jpmorgan.com | 16 Oct 2002 04:48 | |
| Dierk Koenig | 16 Oct 2002 06:30 |
| Subject: | RE: [Webtest] File upload![]() |
|---|---|
| From: | EPu...@upstate.com (EPu...@upstate.com) |
| Date: | 10/16/2002 04:36:13 AM |
| List: | com.canoo.lists.webtest |
Does this mean that you can integrate into Webtest a fileupload test? What does your ant XML look like? Does it just have the location of the file to upload?
If this is working, I would love to see this in CVS since I ended up using raw HTTPUnit and Junit directly to test my file upload code!
+1
Eric Pugh
-----Original Message----- From: skel...@jpmorgan.com [mailto:skel...@jpmorgan.com] Sent: Wednesday, October 16, 2002 7:29 AM To: webt...@gate.canoo.com Subject: [Webtest] File upload
I'm very new to Canoo and HttpUnit, so please bear with me...
There seems to be a problem with submitting forms that contain input boxes of type "file". I always got an exception when doing a ClickButton after using setInputField. I have modified ClickButton.java so that it works for me. There are 2 problems, however. First, I can't use CVS to submit this contribution in the usual way (I mean I can't use CVS here at all, not that there is a problem with it), and 2nd, I assume any field called "file" is a file input field, which is obviously somewhat lacking.
If anyone can tell me how this could be done more generally, I'd be happy to fix it up properly (assuming I ever get CVS...).
Reg Skelton
add: import com.meterware.httpunit.UploadFileSpec
replace (lines 135-158): private void addParameterToRequest(WebRequest request, ParameterHolder parameterHolder) {
List parameterValues = parameterHolder.getValueList(); if(parameterHolder.isPreserveExistingValue()) { String[] existingParameters = request.getParameterValues(parameterHolder.getName()); parameterValues.addAll(Arrays.asList(existingParameters)); }
request.setParameter(parameterHolder.getName(), (String []) parameterValues.toArray(new String[parameterValues.size()])); } with: private void addParameterToRequest(WebRequest request, ParameterHolder parameterHolder) {
List parameterValues = parameterHolder.getValueList(); if(parameterHolder.isPreserveExistingValue()) { String[] existingParameters = request.getParameterValues(parameterHolder.getName()); parameterValues.addAll(Arrays.asList(existingParameters)); }
if( "file".equals( parameterHolder.getName())) { UploadFileSpec[] ufs= new UploadFileSpec[parameterValues.size()];
for( int i=0; i < ufs.length; i++) { ufs[i]= new UploadFileSpec( new java.io.File( (String) parameterValues.get( i))); }
request.setParameter(parameterHolder.getName(), ufs); } else { request.setParameter(parameterHolder.getName(), (String []) parameterValues.toArray(new String[parameterValues.size()])); } }
This communication is for informational purposes only. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. All market prices, data and other information are not warranted as to completeness or accuracy and are subject to change without notice. Any comments or statements made herein do not necessarily reflect those of J.P. Morgan Chase & Co., its subsidiaries and affiliates.
_______________________________________________ WebTest mailing list WebT...@lists.canoo.com http://lists.canoo.com/mailman/listinfo/webtest




