I need to call a web and retrieve the resulting data from the model in my asp.net mvc application. When accessed on the web, the form looks like this:
<form id="textEntryForm" name="textEntryForm" method="post" action="/project/evaluate_to_pdf">
<textarea id="p" rows="20" name="p" cols="132"/><br/>
<input type="button" value="parse" name="do_parse" onclick="new Ajax.Updater('parsedProject','/project/parse',{asynchronous:true,evalScripts:true,on404:function(e){alert('not found!')},parameters:Form.serialize(this.form)});return false"/>
<input type="button" value="evaluate_to_html" name="do_evaluate_to_html" onclick="new Ajax.Updater('parsedProject','/project/evaluate_to_html',{asynchronous:true,evalScripts:true,on404:function(e){alert('not found!')},parameters:Form.serialize(this.form)});return false"/>
<input type="button" value="evaluate" name="do_evaluate" onclick="new Ajax.Updater('parsedProject','/project/evaluate',{asynchronous:true,evalScripts:true,on404:function(e){alert('not found!')},parameters:Form.serialize(this.form)});return false"/>
<input type="button" value="evaluate to pdf source" name="do_evaluate_to_pdf_source" onclick="new Ajax.Updater('parsedProject','/project/evaluate_to_pdf_source',{asynchronous:true,evalScripts:true,on404:function(e){alert('not found!')},parameters:Form.serialize(this.form)});return false"/>
<input type="submit" id="do_evaluate_to_pdf" value="evaluate_to_pdf" name="do_evaluate_to_pdf"/>
</form>
I need to pass the data that would be entered into textarea id="p". How do add that in, using a WebClient to connect?
Thanks!
Edit This isn't for testing purposes, I need to retrieve the data for use in my application.
Agreeing with @wentbackward, WatiN is another alternative.
These things have a habit of becoming more and more complex, for example should you need to handle cookies, authentication or multipart form uploads for uploading files etc. I suggest using curl (http://sourceforge.net/projects/libcurl-net/)
Another option is the Lightweight Test Automation Framework by Microsoft <- Here Steve Sanderson applies it to MVC.
(source: codeville.net)
(source: codeville.net)
I just used this: http://www.eggheadcafe.com/community/aspnet/2/69261/you-can-use-the-webclient.aspx
You create a Stream and pass it into your HttpWebRequest.
http://msdn.microsoft.com/en-us/library/debx8sh9.aspx
Something like this: