Friday, March 20, 2009

How to add local text or tif or pdf files from local PC into the web test scripts

How to add local text or tif or pdf files from local PC into the web test scripts

Hello,
One of our site has a feature to upload document(text, tiff or pdf files) through its User Interface and after uploading the documents they get inserted into some database table and finally they show up to the UI.

I tried to record this by using VSTS 2008 beta/VSTS 2005 SP1 as a web test and it was not working.

I wonder - is there any alternative way or best way to make the script workable for uploading document(tiff file) from local location through the website by VSTS

Thanks,

------------------------------------------------------------------------------------------------


Answer Re: How to add local text or tif or pdf files from local PC into the web test scripts Was this post helpful ?

add the file to your test solution and add it to the deployment section of your test run configuration.

So far this is what we've had to do any time we had a test that uploads a file of any sort to the server

--Chuck
----------------------------------------------------------------------------------------------


Answer Re: How to add local text or tif or pdf files from local PC into the web test scripts Was this post helpful ?

You shouldn't have to add it to the solution, but Chuck is right, you need to add it to the deployment section of your testrunconfig

--Mike


-------------------------------------------------------------------------------------------

Re: How to add local text or tif or pdf files from local PC into the web test scripts

Thanks Chuck and Mike. It helped.

------------------------------------------------------------------------------------------

Re: How to add local text or tif or pdf files from local PC into the web test scripts Was this post helpful ?

Hi Chuck and Mike,Same scenario discussed by Jaeed but let me explain.I have a simple web page with uploading files (any txt, doc or pdf) from any location and after uploading all the files displayed to some UI. I record a web test and during the recording I have successfully upload the text file on my required application. So then according to ur solutions I then add the files to deployment area and then re-run my recorded test, The run successfully but non of the file present in deployment area is uploaded to the required applicaiton. Is there any thing which i missing.Your response in this regard will be highly appreciated.Regards,Waseem.

---------------------------------------------------------------------------------------------


Re: How to add local text or tif or pdf files from local PC into the web test scripts Was this post helpful ?

I presume you are still at the stage of getting the webtest working, and we are running in webtest mode, not loadtest mode.

So did your test generate any errors?

Open up the test results and walk through and examine the responses from the server for each step of the test.. did everything go as expected, or did you get some kind of error from the server.. (especially if you end up trying to do something like upload a file that already exists.. I'd expect some kind of different response from the server than if the file did not already exist (as in some kind of overwrite confirmation)

One thing to keep in mind with VSTS is that when page content is dynamic, if the right page URL is returned in response to the request, in the abscence of other validation checks VSTS will consider that request to be a success, NO MATTER what is actually on the page.
In that instance a very limited number of things could cause the action to fail:
unable to find a match for an extraction rule
total abscence of any hidden values if hidden values are being extracted from the page
404 error for some dependant resource

For example, if I'm doing something to update a user's credit card data on a commerce site.. after posting the data I might get back a page called updatecc.aspx.. On that page might be text to the effect of "Credit Card Updated" or "Invalid Credit Card" or "expiration date required" or some other error..
If I don't add a validation to that page to look for the success message, or to look for error messages and FAIL if they are found, then VSTS can't tell if the actual page content was correct, and the test will pass by default just because a page with the right URL came back.
--Chuck

----------------------------------------------------------------------------------------------


Re: How to add local text or tif or pdf files from local PC into the web test scripts Was this post helpful ?

Hi Chuck,I upload the files on my web application using the same recorded script by changing its some parameters. After recording the test I simply go on the step on which upload URL is present, I then change the file path of FileUploadParameter under the FromPostParameters from its properties and give the path of another file to which I want to upload and then re-run the test and I got success. But still confusing with the option which you told me for files uploading through 'Deployment' area under Test -> Edit Test Run Configurations -> Deployment .Could u plz tell me the steps by executing them I am able to upload the files through Test -> Edit Test Run Configurations -> Deployment option instead of changing the file path of FileUploadParameter .Regards,Waseem

-----------------------------------------------------------------------------------------------


Re: How to add local text or tif or pdf files from local PC into the web test scripts Was this post helpful ?

One of the MS folks might be able to explain this better (and will hopefully correct me if I have any of this wrong), but my general understanding is along these lines.

Webtests get run from more than a single machine.. They could be run by other people in your org (assuming they are checked into source control) and they can end up being run on Agent systems when run as part of a larger scale loadtests or on a dedicated workstation used for smaller scale loadtests.

So the deployment section of the test run configuration is a way to tell the system 'these are files I need to run this test' the items there might be datafiles used for databindings, or files being uploaded, or for some other purpose, but when the test runs it will need access to those files.

This is why (I believe) when a test records a file upload action, what is recorded in the test is only the filename, and not the full path. Because the system is going to expect to find that file in the deployment directory (which is created when the test runs), which is the only place it can reliably know the file will be able to be found. (after all, an agent machine, or a co-worker's system likely does not have access to your hard drive, and may not have access to the same network shares you do.)

So adding the files to the deployment list doesn't upload them anywhere, it's not an alternative to the file upload parameter.. it's a way to make sure whatever you spec in that parameter is available to the test no matter where the test is run.

One thing I'm not clear on is where the system looks for the file when it goes to deploy it. It seems the file needs to be in the same directory as your test. (which is why with my stuff being checked into source control and all, I've been adding the file to the solution.. I'm not sure if it's the 'best' way of dealing with it, but it's working for me so far.)
--Chuck

No comments:

Unix/Linux Commands

  Flow control Syntax break Exit a loop. continue Exit the current iteration of the loop and proceed with the next iteration. Ctrl+C Key com...