Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET library to run performance test for web

I have test written on C# with Selenium Webdriver. now i need testing performance of application. i used FiddlerCore but it doesn't have page rendering time or time of dynamiс content(ajax,js and etc.).

Anybody know library like FiddlerCore but with more features like dynatrace Ajax edition or browsermob-proxy for C#?

EDIT 1: I don't need any solutions. I want to test with WebDriver only.

like image 922
TheX Avatar asked Jan 29 '12 18:01

TheX


1 Answers

I've created performace test use BrowserMob as following
- Download lastest BrowserMob: http://bmp.lightbody.net/
- Get AutomatedTestter.BrowserMob from https://github.com/AutomatedTester/AutomatedTester.BrowserMob
- Get Selenium
- Run following code:

 // Supply the path to the Browsermob Proxy batch file
        Server server =
            new Server(
                @"path\to\browsermob-proxy.bat");
        server.Start();

        Client client = server.CreateProxy();
        client.RemapHost("host", "ip address");
        client.NewHar("google");

        var seleniumProxy = new Proxy { HttpProxy = client.SeleniumProxy };
        var profile = new FirefoxProfile();
        profile.SetProxyPreferences(seleniumProxy);
        // Navigate to the page to retrieve performance stats for
        var driver = new FirefoxDriver(profile);
        driver.Navigate().GoToUrl("http://google.com.vn");


        // Get the performance stats
        HarResult harData = client.GetHar();

        AutomatedTester.BrowserMob.HAR.Log log = harData.Log;
        AutomatedTester.BrowserMob.HAR.Entry[] entries = log.Entries;
        foreach (var entry in entries)
        {
            AutomatedTester.BrowserMob.HAR.Request request = entry.Request;
            var url = request.Url;
            var time = entry.Time;
            Console.WriteLine("Url: " + url + " - Time: " + time);
        }



        driver.Quit();
        client.Close();
        server.Stop();
like image 93
Ha Doan Avatar answered Sep 29 '22 05:09

Ha Doan