Upload
daxia
View
46
Download
2
Tags:
Embed Size (px)
DESCRIPTION
Automated Web Performance Testing Before 5pm. Ian White Mark Watson Simon Nicoud. Build it with us!. CD’s with the required files on them are being passed around Also available here, bandwidth permitting: http://bit.ly/llxuoe. Agenda. Automated web performance testing? - PowerPoint PPT Presentation
Citation preview
Build it with us!CDs with the required files on them are being passed aroundAlso available here, bandwidth permitting:http://bit.ly/llxuoe
Agenda
Automated web performance testing?Tools needed to automate web testingTools used to gather Performance MetricsCombine the two5pm!
End Goal
What is automated web performance testing?
Why?
Tools:Browser automation software Selenium (Watir, QTP, Silk Performer)Metrics gathering softwareBrowserMob Proxy (Fiddler, Web/Resource Timings)HAR Viewer Metrics displaying software
Workshop SetupTutorials are provided in Python & JavaSelenium to automate FirefoxThen later use Proxy to gather page metricsIf you get lost check the READMEs!
Workshop SetupUses FirefoxPython ExamplesSetup PythonSetup Selenium libRun example
Workshop SetupJava ExamplesRequires JDKSelenium lib in jars/Use runtest.sh/bat to runREADME lists examples
Examples
Basic Selenium scriptSelenium script in a unit testTimings and Timeouts per step
Basic Selenium scriptPython:from selenium import webdriver
driver = webdriver.Firefox()driver.get("http://www.google.com")element = driver.find_element_by_name("q")element.send_keys("Cheese!")element.submit()driver.close()
Selenium unit testPython:def testSearch(self): google = self.driver.get("http://www.google.com") element = self.driver.find_element_by_name("q") element.send_keys("Cheese!") element.submit()
Timings and TimeoutsPython: def testSearch(self): with Timeout(10, "Navigate to google.com"): self.driver.get("http://www.google.com")
with Timeout(10, "Search for cheese!"): element =self.driver.find_element_by_name("q") element.send_keys("Cheese!") element.submit()
HAR
HTTP ArchiveSimple format (JSON/JSONP)Tons of data (if you want it)Easily extensibleBecoming the standard
HAR Tools
HarpoonStore/analyze performance test results (HAR)Open SourceGuiceSitebricksMongoDBJettyBuilt in a day (sort of)Source code available: https://github.com/fuzzygroove/harpoon
Harpoonhttp://labs.webmetrics.com:8080/
Which Metrics?Overall page load timeDOM loading/interactive/complete, browser 1st render, Per-item timingsHeaders, status codes, and content
Methods for gathering metricsSetting your own timings in test codeUsing the new Navigation.Timings or Web Timings standard built into browsers Using browser plugins that report back the timings to you, e.g. WebPageTestRouting the browser traffic through a local proxy and gathering the statistics from there.Network traffic capture
Web TimingsCurrently Chrome and IE9 supported, coming soon for firefoxhttp://w3c-test.org/webperf/specs/NavigationTiming/
Unfortunately it doesn't give timings per item downloaded, e.g. images, css, js, ....
Browser PluginsFirefox - Firebug Net Panel + NetExporthttps://github.com/lightbody/browsermob-page-perfhttps://github.com/AutomatedTester/AutomatedTester.PagePerf.git
Capturing page metrics using a proxy
Many available, but few capture metrics in a convenient wayTwo good ones well be looking at:BrowserMob ProxyFiddler
Advantages of using a ProxyWorks with any browser that allows setting a proxyTesting benefits beyond performance monitoringBlacklisting/whitelisting URLsURL rewritesMake sure specific URLs are visited
Advantages of using a ProxyHeader changesSet the user agent manually to test different browser behaviorAuto authentication
Wait until all content is downloadedHTTP idle for X seconds
Simulate limited bandwidth
BrowserMob Proxy
Open source cross platform proxyHTTP Archive supportNative Java APIREST API for calling from other languages
Source code available:https://github.com/lightbody/browsermob-proxy
BrowserMob ProxyJava Examples:Write out HTTP Archive file
Separate pages in the HAR
proxy.newHar(Main Page); ...load main page... proxy.endPage(); proxy.newPage(Login"); ...login... proxy.endPage();
proxy.getHar().writeTo(new File("test.har"));
BrowserMob Proxy
Redirecting URLs
proxy.blacklistRequests(regex, responseCode)proxy.whitelistRequests(regex, responseCode)
Blacklist/Whitelist URLs
proxy.rewriteUrl(regex, replace)
Limit Bandwidth
proxy.setDownstreamKbps(kbps)proxy.setUpstreamKbps(kbps)
BrowserMob Proxy
Python Demo:First, start the proxy:
Then, run the examples:
BrowserMob Proxy
Selenium test with HAR export
BrowserMob Proxy
Whitelist exampleCompare site load time with and without 3rd party content
BrowserMob Proxy
Limit BandwidthCompare site load time with different bandwidth restrictions
BrowserMob Proxy
HAR uploadLast example uploads results of each test to central server.
Optimize for TestingDumb stuffDont use nested iframesAvoid popupsTough stuffDynamic elementsEmbedded objectsMobileGood stuffAutomated test frameworkContinuous Integration
LinksBrowserMob proxyhttps://github.com/lightbody/browsermob-proxy
Harpoonhttps://github.com/fuzzygroove/harpoon
Examples from this talkhttps://github.com/watsonmw/automated-pageloadmetrics
Simon Nicoud: [email protected] - @simonnicoud Ian White: [email protected] - @impressiverMark Watson: [email protected] - @watsonmw
*
*
*****************
*****
************