Capture http traffic when click on a link

9 posts, 0 answers
  1. Terri
    Terri avatar
    12 posts
    Member since:
    Feb 2012

    Posted 11 Jun 2012 Link to this post

    Hi,

    I have created an utility class to capture HTTP Traffic (to get some querystring key/value pair) by using Telerik HTTP PROXY class, triggered by launching a URL. This part is more complicated but it's done.

    I need to capture the same traffic by clicking on any link on a page; all I know is the link element user clicked, but I won't know the exact URL. This test has to be done from Test Studio as the QA tester is not as technical, most likely with data binding to a set of link elements.

    I am new to Test Studio, thought this should be pretty straightforward. Can anyone help? 

    Thanks,
    Terri
  2. Terri
    Terri avatar
    12 posts
    Member since:
    Feb 2012

    Posted 12 Jun 2012 Link to this post


    The link element is:
    <a class="nav-item-link-primary" onclick="PartnerLink('nx','invneeds_'+s.prop2+_global', ",this); href="/destination/">

    My delima is, I need to capture the http traffic starting at the onclick event, before reaching the href destination. I don't have an URL at that point. Not sure if I can use  ActiveBrowser.url to retrieve the url and pass to my utility function. 

    Can anyone help?

    Thanks

     

  3. Daniel
    Daniel avatar
    1 posts
    Member since:
    Jul 2011

    Posted 12 Jun 2012 Link to this post

    Terri - 
    It is possible to pass the browser object to another method, but I believe that you class needs to inherit the BaseTest class.

    You can see and example that I did with the framework a while back in a stackover flow answer.  http://stackoverflow.com/questions/6987181/does-the-webaii-framework-support-a-page-class-structure-in-the-way-that-watin-d/7029320#7029320 

    I also played a little with the HTTP proxy - this is how I ended up structuring that call.
    [CodedStep(@"Click 'Bulk Reports link'")]
    public void TradeList_CodedStep3()
    {
        ResponseListenerInfo li = new ResponseListenerInfo(GetFileFromHeaderInfo);
        Manager.Http.AddBeforeResponseListener(li);
     
         //Click Bulk reports link
        Pages.TamaracIncCom7.Find.ById<HtmlAnchor>("ctl00_ContentPlaceHolder_rwDldFiles_C_lbGenerateBulkReport").Click(false);
     
        Manager.Http.RemoveBeforeResponseListener(li);
     
        string fileName = (string)GetExtractedValue("acctTradeFile");
     
        string fullPath = @"C:\temp\SmokeTestDownloads\" + fileName;
        SetExtractedValue("fullPath", fullPath);
     
     
    }

    I hope that helps.

  4. Terri
    Terri avatar
    12 posts
    Member since:
    Feb 2012

    Posted 13 Jun 2012 Link to this post

    Hi, Daniel,
    Looks like you have stumbled with the issue I am encourting already. Thanks for your answer. I see you had an old thread on Nullreference to the http object issue, I had tried to reply to that thread but failed.

    To get around the Test Studio doesn't work with http Proxy issue, could you share how exactly you did by adding a test settings file to the project and enabling it ... I have tried to add an app.config file and it doesn't seem to work.
    Thank you very much for your help.
  5. Daniel
    Daniel avatar
    1 posts
    Member since:
    Jul 2011

    Posted 13 Jun 2012 Link to this post

    Teri - 
    I am working with the visual studio plugin of Test Studio so this is how I did it.

    1. I added a settings file to my project:
    http://www.telerik.com/automated-testing-tools/support/documentation/user-guide/test-execution/test-list-settings.aspx 

    2. Under the web tab in the Telerik section of that file you can turn on the HTTP proxy.

    3. Because you have the settings file now you will also need to go the deployment section and check the Enable Deployment button.

    4. I have to run this then by debugging a given test (not quick executing.)  You can do this by opening the Test View.  In VS, Test -> Windows -> Test View.  Then select the test in the list and select the test you want to debug and right click it and debug the selection.
  6. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 14 Jun 2012 Link to this post

    @Terri
    Do you require further assistance after following Daniel's suggestions?

    @Daniel
    Thank you for assisting another user. I updated your Telerik points accordingly.

     

    Regards,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  7. Terri
    Terri avatar
    12 posts
    Member since:
    Feb 2012

    Posted 14 Jun 2012 Link to this post

    Hi, Anthony,

    Yes, I do have more questions, thanks for following up. I followed Daniel's instruction and get to the point I wanted, THANKS Daniel!

    However, my goal is to develop a process for QA folks to execute my test in Test Studio. I need to use the ArtOfTest.Runner.exe to generate  .aiiresult file on a shared drive so later we can copy that file to our local result folder to be included in the matrix report.

    Questions:
    1. This is the MSTest and Telerik Test related question - when I create a test list for the test in VS-plugin, the list is in the .vsmdi file, and I have noway to execute it from the ArtOfTest.Runner.exe, can only execute on the test. Is this right?

    2. On the original thread,
    http://www.telerik.com/automated-testing-tools/community/forums/test-studio-express/general-discussions/null-reference-exception-when-trying-to-use-the-http-proxy.aspx, I don't quite understand the get around. Any document on the RunHelper?

    Thanks,
    Terri
  8. Anthony
    Admin
    Anthony avatar
    19 posts

    Posted 14 Jun 2012 Link to this post

    Hello Terri,

    1. ArtOfTest.Runner can execute a test file (.tstest or .aii) or a Test Studio Test List (.aiilist). Visual Studio Test Lists must be executed with MSTest and won't generate an .aiiresult file. This is because it's using Microsoft's execution engine and not Test Studio's.

    2. RunHelper wraps test execution so it can be called from third party apps. Here is our documentation on it (albeit minimal).

    The work-around is a parent test that contains a single coded step. That code turns the HttpProxy on (which cannot be done through the UI for Quick Execution) and then executes the target test via RunHelper.

    The HttpProxy setting can be toggled through the UI for Test Lists, however, so if you execute that way the work-around won't be needed.

    Greetings,
    Anthony
    the Telerik team
    Quickly become an expert in Test Studio, check out our new training sessions!
    Test Studio Trainings
  9. Terri
    Terri avatar
    12 posts
    Member since:
    Feb 2012

    Posted 10 Jul 2012 Link to this post

    sorry, remove the post.
Back to Top