This is a migrated thread and some comments may be shown as answers.

How to read multiple Omniture calls through Proxy in Test Studio

1 Answer 104 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 1
Drew asked on 07 Dec 2015, 07:34 PM

Hello, 

Sorry in advance if I didn't format this correctly, first time poster.

I'm currently working on developing tests to read omniture tags being sent from websites to Site Catalyst database. Most of these calls occur on page load or through certain button clicks i.e. "add to cart" and must have their data captured and verified after going through a proxy. Based on previous forum posts I've been able to build a coded module that has Telerik start a proxy, then goes to the site, then checks the calls for the host under which the omniture call is made and captures that data. 

My problem occurs whenever there are multiple calls that happen from the same button. Currently I can only capture 1 call, and it's random which one will fire first, so I need to be able to see both, capture both, then check if the values are correct.

 

I've attached the following:

HTTP proxy module I built that starts the proxy and also contains methods to click on certain buttons and listen for the calls then returns a dictionary

The Dictionary Lookup module defines methods that allow the us to compare key value pairs in the dictionary with our asserts.

WebTest(1) which puts all these steps together. 

 

Below is the method I use to click on the "add to cart" button and wait for an omniture to be made and stores the data in a dictionary and returns it. I feel like this is what I need to modify in order to capture two calls instead of just one. 

        public Dictionary<string, string> ClickAddToCartButtonAndListen()
        {
            found = false;
            
            Console.WriteLine("Omniture Url: " + omnitureUrl); //DEBUGGING
            
            // Add our HTTP response event handler. For each response the proxy gets, parse for the Omniture URL's query string parameters
            ResponseListenerInfo li = new ResponseListenerInfo(GetQueryStringParamatersAndValues);
            Manager.Current.Http.AddBeforeResponseListener(li);
            
            // Click 'Add to Cart Button'
            Pages.OfficialVailVailLift.Button.Click(false);
            
           
           
            
            // Wait for the page to completely load
            Manager.Current.ActiveBrowser.Frames.WaitAllUntilReady();
            Manager.Current.ActiveBrowser.WaitUntilReady();
            Manager.Current.ActiveBrowser.WaitForAjax(15000);
            
            // Wait for '1000' msec. (this is to conpensate for the Omniture pixel being one of the last things called
            System.Threading.Thread.Sleep(1000);
            
            // We don't need the event handler any longer. Removing it stops listening to responses in the proxy
            Manager.Current.Http.RemoveBeforeResponseListener(li);
            
            return dictionary;
        }

 

 

1 Answer, 1 is accepted

Sort by
0
Cody
Telerik team
answered on 08 Dec 2015, 10:55 PM
Hello Drew,

I've carefully studied all the information you supplied to us and I don't see any problems with our HTTP proxy itself. I see in your code where your logging to the console the URL of every outgoing request. I then modified your web test to navigate to http://www.vail.com/and click on the add to cart button. I can see 2 Omniture calls going out on the wire and studying the console output I see both of them being logged in the console. I have attached the console output as a file attachment so we can see what's actually being logged in the console window. It shows 2 Omniture calls being made in addition to one other outgoing request which is not an Omniture request.

Looking further into your code I see a found flag inside the proxy listener. The way this flag is being used it looks like it will force the code to accept the first one and only the first one and reject any at follow-on matching URLs. See the highlighted lines in the following code:
private void GetQueryStringParamatersAndValues(object sender, HttpResponseEventArgs e)
{
 
    Console.WriteLine("URL: " + e.Response.Request.RequestUri + "\n\n"); // DEBUGGING
 
    if (found == false)
    {
        // Get the current RequestUri
        String currentRequestUri = e.Response.Request.RequestUri;
 
        // If the current request uri begins with the omnitureUrl
        if (currentRequestUri.Contains(omnitureUrl))
        {
            // Set found flag to true
            found = true;

If you want to capture multiple outgoing Omniture requests why are you setting a found flag then excluding follow-up requests when this flag is set?

Regards,
Cody
Telerik
 
The New Release of Telerik Test Studio Is Here! Download, install,
and send us your feedback!
Tags
General Discussions
Asked by
Drew
Top achievements
Rank 1
Answers by
Cody
Telerik team
Share this question
or