Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upload a file through a microsoft webtest

Tags:

I have a .webtest that I am intending to use to load test uploading a file to a website. I am using the webtest framework that is built into visual studio with the intention of running my larger scale tests from azure.

I created a new webtest and recorded the steps, including the file upload. This all recorded correctly, but the problem is that the File Upload Parameter was just recorded the filename (not the bytes). This means that the test needs to have access to the file that will be uploaded during running.

Recorded upload

I also added the file to the project and set it to be content. Content file

The problem is that the file isn't getting copied over during running. I found a blog post https://blogs.msdn.microsoft.com/edglas/2008/08/05/how-to-upload-a-file-in-a-web-test/ which appears to answer my question but the visual studio ui has changed and the option is no longer available.

I cannot use an absolute url c:\files\filename.docx because i need to run this from azure.

I also cannot post the file somewhere on the internet because it has to be a path, not a url.

I have posted a queston to the blog post, but it doesn't seem very active and am really at a lose for where to go from here.

TIA, -Logan

like image 977
Logan Avatar asked Dec 05 '16 22:12

Logan


People also ask

How do I upload a file to a test project?

Upload File using XPath - This is an action that requires the XPath of the input element: //input[@type = 'file']. The second parameter is of course, the local path to the file you want to upload. Upload file to input element - This is an element action and you need to use it on the input element.


1 Answers

The "Deployment" functionality shown in the last screenshot of Ed Glass's blog is now in the .testsettings files of the solution. (The blog shows a window with a "localtestrun.testrunconfig" file.) If you have more than one .testsettings file then ensure that the context menu of the correct file has the "Active load and web test settings" ticked.

In the deployment section of the .testsettings file, tick "Enable deployment" and add the directory or file(s) to be used in the tests. After running a test you should then find that the items have been copied into a subdirectory of the TestResults\{{name+date+time}} directory, as described in the blog.

New .testsettings files can be added to a solution as follows. From the context menu of the solution (the topmost item in Solution Explorer), select Add => New item => Test settings (from the left hand side of the "Add new item" window), then fill in the forms. New files can also be created via the "Save as" button in the test settings editor, but this requires a file to already be open.

When creating new .testsettings files I recommend changing the "Name" field in the "General" section to match the filename. Not doing so (after using "Save as") has left me confused because two or more files appear to have the same name. I normally have up to three .testsettings file in a solution: One for local use when developing tests. Another (often named "cloud" or "vsts") configured for cloud load testing with VSTS. The third version (often named "agent" or "remote") for use with controllers and agents.

like image 147
AdrianHHH Avatar answered Sep 23 '22 16:09

AdrianHHH