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

Capture http traffic when click on a link

8 Answers 76 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Terri
Top achievements
Rank 1
Terri asked on 11 Jun 2012, 06:15 PM
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

8 Answers, 1 is accepted

Sort by
0
Terri
Top achievements
Rank 1
answered on 12 Jun 2012, 05:21 PM

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

 

0
Daniel
Top achievements
Rank 1
answered on 12 Jun 2012, 07:11 PM
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.

0
Terri
Top achievements
Rank 1
answered on 13 Jun 2012, 09:36 PM
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.
0
Daniel
Top achievements
Rank 1
answered on 13 Jun 2012, 09:48 PM
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.
0
Anthony
Telerik team
answered on 14 Jun 2012, 08:02 PM
@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
0
Terri
Top achievements
Rank 1
answered on 14 Jun 2012, 08:40 PM
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
0
Anthony
Telerik team
answered on 14 Jun 2012, 10:58 PM
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
0
Terri
Top achievements
Rank 1
answered on 10 Jul 2012, 09:54 PM
sorry, remove the post.
Tags
General Discussions
Asked by
Terri
Top achievements
Rank 1
Answers by
Terri
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Anthony
Telerik team
Share this question
or