KEMBAR78
Web performance testing with web driver | PDF
Web Performance Testing
with WebDriver
An integrated approach
Michael Klepikov
Make the Web Faster Team, Google
developers.google.com/speed
webpagetest.org
■ +1s load => -7% conversion rate
■ Just better user experience
■ Mobile exacerbates slowness
■ 46% mobile users abandon after 10s
Why is it important?
■ WebPageTest.org
■ Waterfall chart
■ Simulated latency
■ Many iterations for statistical validity
Page Load performance
Interactive scenarios
■ Multi-page
■ Login
■ Placing an order
■ AJAX is a better user experience
Test Systems Integration
■ WebPageTest is a separate system
■ Everyone has a custom toolchain
■ Hard to integrate
■ Not a seamless developer experience
■ Standard WD API:
○ Session Capabilities
○ Logging
■ Easy to enable in existing tests
■ Fits well into existing toolchains
Build it into WebDriver itself
■ LoggingPreferences
in WD capabilities
// Ask Chrome to collect "performance" log
DesiredCapabilities caps = DesiredCapabilities.chrome();
LoggingPreferences logPrefs = new LoggingPreferences();
logPrefs.enable("performance", Level.INFO);
caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs);
driver = new RemoteWebDriver("http://localhost:9515", caps);
WD API: Create Driver
■ Plain functional test, nothing special
■ Free magic for developers!
■ Pro tip: console.time()+timeEnd(), timeStamp()
driver.get("http://www.google.com/");
WebElement element = driver.findElement(By.name("q"));
element.sendKeys("GTAC 2013");
element.submit();
WD API: Run Test
■ Not part of test per se, inject:
○ In tearDown()
○ Override WebDriver.quit()
○ WebDriver HTTP-JSON proxy
log = driver.manage().logs().get("performance").getAll();
for (LogEntry entry : log) {
// WebDriver LogEntry message is a JSON string
JSONObject m = new JSONObject(entry.getMessage());
... m.getString("webview") ... // Originating WebView id
... m.getJSONObject("message") ... // Raw DevTools event
WD API: Get Performance Log
Performance Analysis
Demo
https://gist.github.com/klepikov/5457750
■ No WD within instrumented intervals
■ Aggregate over multiple iterations!
■ Run frontend in maximum isolation
○ Mock/stub/fake backends
■ Use WebPageReplay
Stable Repeatable Results

Web performance testing with web driver

  • 1.
    Web Performance Testing withWebDriver An integrated approach Michael Klepikov Make the Web Faster Team, Google developers.google.com/speed webpagetest.org
  • 2.
    ■ +1s load=> -7% conversion rate ■ Just better user experience ■ Mobile exacerbates slowness ■ 46% mobile users abandon after 10s Why is it important?
  • 3.
    ■ WebPageTest.org ■ Waterfallchart ■ Simulated latency ■ Many iterations for statistical validity Page Load performance
  • 4.
    Interactive scenarios ■ Multi-page ■Login ■ Placing an order ■ AJAX is a better user experience
  • 5.
    Test Systems Integration ■WebPageTest is a separate system ■ Everyone has a custom toolchain ■ Hard to integrate ■ Not a seamless developer experience
  • 6.
    ■ Standard WDAPI: ○ Session Capabilities ○ Logging ■ Easy to enable in existing tests ■ Fits well into existing toolchains Build it into WebDriver itself
  • 7.
    ■ LoggingPreferences in WDcapabilities // Ask Chrome to collect "performance" log DesiredCapabilities caps = DesiredCapabilities.chrome(); LoggingPreferences logPrefs = new LoggingPreferences(); logPrefs.enable("performance", Level.INFO); caps.setCapability(CapabilityType.LOGGING_PREFS, logPrefs); driver = new RemoteWebDriver("http://localhost:9515", caps); WD API: Create Driver
  • 8.
    ■ Plain functionaltest, nothing special ■ Free magic for developers! ■ Pro tip: console.time()+timeEnd(), timeStamp() driver.get("http://www.google.com/"); WebElement element = driver.findElement(By.name("q")); element.sendKeys("GTAC 2013"); element.submit(); WD API: Run Test
  • 9.
    ■ Not partof test per se, inject: ○ In tearDown() ○ Override WebDriver.quit() ○ WebDriver HTTP-JSON proxy log = driver.manage().logs().get("performance").getAll(); for (LogEntry entry : log) { // WebDriver LogEntry message is a JSON string JSONObject m = new JSONObject(entry.getMessage()); ... m.getString("webview") ... // Originating WebView id ... m.getJSONObject("message") ... // Raw DevTools event WD API: Get Performance Log
  • 10.
  • 11.
  • 12.
    ■ No WDwithin instrumented intervals ■ Aggregate over multiple iterations! ■ Run frontend in maximum isolation ○ Mock/stub/fake backends ■ Use WebPageReplay Stable Repeatable Results