Capturing HTTP traffic

Short version:
I'm looking to make sure that a URL (partial match) is being requested (client side).

Long version:
I'm looking to automate part of my testing. I am currently using Fiddler2 for manual verification.

Here's the script:

  • User goes to site A
  • My application redirects the tracking URL (see Fiddler HTTP traffic)
  • The user gets to site A, the parameters are now applied.

I would like to check in C # that step 2 happened by a partial match (for example, it contains {string}).

Question:
How do I do this? I started to study the class HttpWebRequestand FiddlerCore, but my love using the simplest code (so that other members of the team to update if necessary) make me ask what the users of StackOverflow recommend.

+5
source share
4 answers

Follow Up: I ended up using Telerik proxy to send HTTP requests and analyzed the responses through C #. Here's an article that was used as a springboard:

https://docs.telerik.com/teststudio/advanced-topics/coded-samples/general/using-the-http-proxy

0
source
+7

: # 2 URL-, , , () . Selenium .

WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;

// Call any javascript
var referrer = js.executeScript("document.referrer");

Selenium Webdriver -/ #. NUnit, MSTest - .

Selenium Webdriver (Firefox, Chrome, Internet Explorer, PhantomJS ) #. , " URL" " " " ". API.

: , , , . , ( , ) .

URL- 1, URL- 3.

, API Selenium-WebDriver . URL {string} ( "" ), , .

using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;

// Requires reference to WebDriver.Support.dll
using OpenQA.Selenium.Support.UI;

class RedirectThenReadUrl
{
    static void Main(string[] args)
    {
        // Create a new instance of the Firefox driver.

        // Notice that the remainder of the code relies on the interface, 
        // not the implementation.

        // Further note that other drivers (InternetExplorerDriver,
        // ChromeDriver, etc.) will require further configuration 
        // before this example will work. See the wiki pages for the
        // individual drivers at http://code.google.com/p/selenium/wiki
        // for further information.
        IWebDriver driver = new FirefoxDriver();

        //Notice navigation is slightly different than the Java version
        //This is because 'get' is a keyword in C#
        driver.Navigate().GoToUrl("http://www.google.com/");

        // Print the original URL
        System.Console.WriteLine("Page url is: " + driver.Url);

        // @kirbycope: In your case, the redirect happens here - you just have
        // to wait for the new page to load before reading the new values

        // Wait for the page to load, timeout after 10 seconds
        WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
        wait.Until((d) => { return d.Url.ToLower().Contains("cheese"); });

        // Print the redirected URL
        System.Console.WriteLine("Page url is: " + driver.Url);

        //Close the browser
        driver.Quit();
    }
}
+1

Looks like you want to sniff out HTTP traffic. You can use the packet capture driver such as winpcap, import the DLL and test, or use the SharpPcap mentioned by @SimpleCoder.

The path of minimal effort is to write a FiddlerScript Addon to check the request and redirect if necessary.

0
source

All Articles