locked
Disable Javascript for validation test on server side

    Question

  • Q: How can I disable Javascript on a specific Request using Web Test, so that I can test the Validation logic on server side?

    Thank you,
    -Rick

    Monday, October 19, 2009 8:44 PM

Answers

  • Here are 2 good articles you should probably read:
    http://msdn.microsoft.com/en-us/library/ms404678.aspx
    http://msdn.microsoft.com/en-us/library/cc678655.aspx

    I have underlined a couple excerpts from those links (below) that I think will answer your question.  In summary though the web test engine does not execute javascript.

    JavaScript

    Usually, you will not have to add any special handling to your Web test for JavaScript in your Web application. While you record your Web test, JavaScript will run as expected, according to your Internet Explorer settings. Any values produced by JavaScript for use as form parameters or query string parameters will be captured by the Web test recorder. When you run your Web test with the Web test engine, the JavaScript will not run, but the parameter values set during recording will be used.

    JavaScript and Coded Web Tests

    Some Web applications depend on JavaScript in ways that affect the HTTP requests. You can use coded a Web test to simulate the logic typically performed by JavaScript. For example, an application might use JavaScript to dynamically modify form parameters. In a coded Web test you can write code to make the same modifications to form parameters manually. For more information, see How to: Create a Coded Web Test.


    Tim
    • Marked as answer by Rick Zhong Tuesday, October 20, 2009 11:18 PM
    Tuesday, October 20, 2009 5:38 PM

All replies

  • The VSTS web test recorder works at the HTTP level (it records the trafic, not what is going on on the client side).  At playback time it uses its own web test engine and does not execute or test your client side Javascript.    Best practice in web site development dictates that even if you do client-side validation you still should perform validation server side so ping your developers, I suspect you are doing your server side validation whether or not the javascript executes on the client.
    Tim
    Tuesday, October 20, 2009 1:00 AM
  • You are right, Tim, By using fiddler I had confirmed that it was actually the server side validation doing the work when submitted. Do you mean that even VSTS 2008 won't be able to pickup(validate) the change happened on client side(javascript)? - if so, how does MS Testing Framework actually address Client Side Validation webtest?

    Thank you,
    -Rick

    Tuesday, October 20, 2009 5:08 PM
  • Here are 2 good articles you should probably read:
    http://msdn.microsoft.com/en-us/library/ms404678.aspx
    http://msdn.microsoft.com/en-us/library/cc678655.aspx

    I have underlined a couple excerpts from those links (below) that I think will answer your question.  In summary though the web test engine does not execute javascript.

    JavaScript

    Usually, you will not have to add any special handling to your Web test for JavaScript in your Web application. While you record your Web test, JavaScript will run as expected, according to your Internet Explorer settings. Any values produced by JavaScript for use as form parameters or query string parameters will be captured by the Web test recorder. When you run your Web test with the Web test engine, the JavaScript will not run, but the parameter values set during recording will be used.

    JavaScript and Coded Web Tests

    Some Web applications depend on JavaScript in ways that affect the HTTP requests. You can use coded a Web test to simulate the logic typically performed by JavaScript. For example, an application might use JavaScript to dynamically modify form parameters. In a coded Web test you can write code to make the same modifications to form parameters manually. For more information, see How to: Create a Coded Web Test.


    Tim
    • Marked as answer by Rick Zhong Tuesday, October 20, 2009 11:18 PM
    Tuesday, October 20, 2009 5:38 PM
  • Here are some URLs I found useful:

    Conclusion: Web Test can't handle client side javascript, it only generates Requests(which can be generated with client javascript) and works with corresponding server Responses.

    Thanks,
    -Rick


    Tuesday, October 20, 2009 11:17 PM
  • VSTS 2010 will have a better answer for you in terms of testing the client side of things.  Not because the web test capabilities will change substantially but because there is a new test run recorder to help out with testing client side logic.

    Have a look at my blog entry for a peek at what testing a WPF app looks like  (it could have just as easily been a web app).  Beta 2 became available to MSDN subscribers yesterday.   

    http://timsbrownbaglunch.blogspot.com/2009/09/vsts-2010-test-run-recording.html
    Tim
    Wednesday, October 21, 2009 12:32 PM
  • Thanks for the info.: I'd check out the Beta 2 later, our team is going to keep using VSTS2008 for the moment.
    -Rick
    Wednesday, October 21, 2009 4:51 PM