Export Sessions extensibility

90 views
Skip to first unread message

Robert Dailey

unread,
Mar 20, 2014, 9:29:02 PM3/20/14
to httpf...@googlegroups.com

This may be a crazy question, so I apologize in advance if it is.  Is it possible to extend the existing export web test code to include new parameter types?  I'm currently exploring the possibility of trying to add the ability to parametrize Json data during export or Fiddler sessions as a VS web test.

In case of noob-speak getting in the way of what I'm trying to say, I'll try and provide context for what I'm hoping to do.  Currently, it is possible to create custom Fiddler plugins to handle parametrization and insertion of extraction rules for Form Post and Query String parameters, right out of the box with Fiddler (I'm using v4.4.6.1 currently.) I love this ability, and would like to extend it to include Json parameters.

Now for where I seem to be stuck <<noob alert!!>>  I thought this would be as simple as extending the WebTestSession class to include new parameter and parameter collection types that handle all that is JSON.  Where I seem to have gotten stuck, however, is that I can't seem to extend the class and then use it.  I tried just simply creating a new class that inherits the The original WebTestSession class; hoping to start working on extending the new class.  However, once doing this, I can't assign FiddlerWebTest.Sessions to the new WebTestSession type.

Simplified pseudo code example of what I mean:

Current code:
            for (int i = 0; i < e.FiddlerWebTest.Sessions.Count; i++)
            {
                WebTestSession sessionRequest = e.FiddlerWebTest.Sessions[i];
                sessionRequest.FiddlerSession.utilDecodeRequest();
                foreach (QueryStringParameter qsParam in sessionRequest.RequestQueryParams) {--do stuff--}
                foreach (FormPostParameter fpParam in sessionRequest.RequestFormParams) {--do stuff--}
            }

My kind of a "Hello World" sort of use case was to then try and extend the WebTestSession, but not yet add anything to the new extension:

using Fiddler;
using System;

namespace Fiddler.WebTesting
{
    public class ExtendedWebTestSession : WebTestSession
    {

        public ExtendedWebTestSession(Session Session) : base(Session) { }
     
    }
}

>>above is where the definitions for the json parameters and how to handle/parse them would start going... assuming I was on the right track<<

And then use this in the same code that was using the base WebTestSession:

            for (int i = 0; i < e.FiddlerWebTest.Sessions.Count; i++)
            {
                ExtendedWebTestSession sessionRequest = e.FiddlerWebTest.Sessions[i];
                sessionRequest.FiddlerSession.utilDecodeRequest();
                foreach (QueryStringParameter qsParam in sessionRequest.RequestQueryParams) {--do stuff--}
                foreach (FormPostParameter fpParam in sessionRequest.RequestFormParams) {--do stuff--}
            }
           
           >>Above code throws immediate error about not being able to do the implicitly convert the type <<


For reasons that I'm sure are obvious to others besides myself, this does not work.  Doing an explicit cast on e.FiddlerWebTest.Session[i] also does not work.  The primary difference is just that explicit casting gets the compiler to say "fine, do it your way dummy" and waits until I try using the code to tell me it can't do the cast.

            for (int i = 0; i < e.FiddlerWebTest.Sessions.Count; i++)
            {
                ExtendedWebTestSession session =  (ExtendedWebTestSession) e.FiddlerWebTest.Sessions[i];
                     --code for handling parametarization.  Can look for Query String and Form Post parameters for doing custom work --
            }

            >>Above  "builds" cleanly, but then fails at execution with an unable to cast the type correctly.<<


Based on my current status, I can safely assume that my approach is wrong... at least in part... before getting any deeper into things, I thought I would throw the question out to the community:

What is the best way to approach accomplishing what I'm trying to do?

EricLaw

unread,
Mar 22, 2014, 12:32:56 PM3/22/14
to httpf...@googlegroups.com
Stepping back a bit:

Fiddler's extensibility model offers the ability to write new Export (and Import) plugins. These are called Transcoders; and their API is documented here: http://docs.telerik.com/fiddler/extend-fiddler/ImporterExporterInterfaces

One of the default Transcoders is the Visual Studio Web Test Export transcoder. This transcoder itself offers its own form of extensibility; when you're choose to export using this Transcoder, it itself offers a dialog to allow you to choose which .webtest plugins you want to execute as a part of the export process. Some documentation for that extension model is found here: http://blogs.msdn.com/b/slumley/archive/2007/04/17/writing-fiddler-web-test-plugins.aspx?Redirected=true and here: http://blogs.msdn.com/b/slumley/archive/2007/04/18/another-fiddler-plugin-example.aspx

-Eric
Reply all
Reply to author
Forward
0 new messages