{"id":12994,"date":"2020-07-07T22:16:00","date_gmt":"2020-07-07T22:16:00","guid":{"rendered":"http:\/\/abstracta.us\/blog\/?p=12994"},"modified":"2025-05-05T21:22:44","modified_gmt":"2025-05-05T21:22:44","slug":"webdriver-vs-chrome-devtools-speed-test","status":"publish","type":"post","link":"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/","title":{"rendered":"WebDriver vs Chrome DevTools (Speed Test)"},"content":{"rendered":"\n<h1 class=\"wp-block-heading\">Comparing the two protocols to beat a fun automation game <\/h1>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>I was inspired recently by Federico Toledo to write a test script that can automate a simple clicking game, but with a focus on executing as fast as possible.<\/p>\n\n\n\n<blockquote class=\"twitter-tweet\"><p lang=\"en\" dir=\"ltr\">Test automation challenge: Can you prepare a test script to win the game 1to50 automatically as fast as possible <a href=\"https:\/\/t.co\/H6mwYxeKko\">https:\/\/t.co\/H6mwYxeKko<\/a>???<br><br>My solution with Ruby and Selenium took 4.9secs to win the game and I know it can be faster <a href=\"https:\/\/t.co\/HadbaCzien\">https:\/\/t.co\/HadbaCzien<\/a> <a href=\"https:\/\/t.co\/UrPDh2bfGX\">pic.twitter.com\/UrPDh2bfGX<\/a><\/p>\u2014 Federico Toledo (@fltoledo) <a href=\"https:\/\/twitter.com\/fltoledo\/status\/1248789014632476672?ref_src=twsrc%5Etfw\">April 11, 2020<\/a><\/blockquote> <script async=\"\" src=\"https:\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>This challenge inspired me to use my favorite Web Testing Framework,&nbsp;<a href=\"https:\/\/webdriver.io\/\">webdriverIO<\/a>,&nbsp;which supports Chrome DevTools and WebDriver protocols out-of-the-box with minor setup. <\/p>\n\n\n\n<p>So I decided to try and see which protocol executes faster.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Lets_Explain_the_Details_First\"><\/span>Let&#8217;s Explain the Details First<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In order to make your tests scripts execute actions against a website, your test framework has to use an interface which is actually capable of controlling the browser.<\/p>\n\n\n\n<p>There are 2 very popular interfaces that allow this to happen. Selenium uses&nbsp;<strong>WebDriver<\/strong>&nbsp;(w3c protocol) which is today the most popular one, but there is also&nbsp;<strong>Chrome DevTools<\/strong>&nbsp;which is native to chromium browsers and has some benefits and disadvantages over its competitor.<\/p>\n\n\n\n<p>In this post we are focusing on speed and&nbsp;<strong><em>spoiler alert<\/em>:&nbsp;our winner is DevTools.<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Heres_Why\"><\/span>Here&#8217;s Why!<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>WebDriver sits in the middle between the test scripts and the browser and uses http traffic to communicate back and forth which can cause a small latency between the execution and the response from the browser.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--mgX314HT--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/z9vv3vqm71k2mlqb766l.png\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--mgX314HT--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/z9vv3vqm71k2mlqb766l.png\" alt=\"Alt Text\"\/><\/a><\/figure><\/div>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>On the other hand, Chrome DevTools allows direct control over the browser by using the&nbsp;<a href=\"https:\/\/developers.google.com\/web\/tools\/puppeteer\">Puppeteer library<\/a>&nbsp;which is finally used by webdriverIO. This means direct execution and less latency in the results.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><a href=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--3pkp_Jtr--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/wq817yh0nrgu8m38gjdb.png\"><img decoding=\"async\" src=\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--3pkp_Jtr--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/wq817yh0nrgu8m38gjdb.png\" alt=\"Alt Text\"\/><\/a><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Lets_Do_the_Test\"><\/span>Let&#8217;s Do the Test<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>The idea of the <a href=\"https:\/\/zzzscore.com\/1to50\/en\/?ts=1592666149743\">game<\/a> is to click the numbers from 1 to 50 as fast as possible, but only the next 25 are displayed. So if you click 1 then the 26th appears.&nbsp;<\/p>\n\n\n\n<p>I created a simple script using webdriverIO on standalone mode so that it runs fast without all the test framework setup.<br><\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>const { remote } = require('webdriverio');\n(async () => {\n    const browser = await remote({\n        logLevel: 'trace', capabilities: { browserName: 'chrome'}\n    })\n    await browser.url('https:\/\/zzzscore.com\/1to50\/en\/?ts=1592666149743') \/\/ navigate\n    for(i = 1; i&lt;51; i++){\n        var element = await browser.$('\/\/div[text()=\"@id\"]'.replace('@id',i))\n        await element.click(); \/\/click each number\n    }\n    var result = await browser.$('.level');\n    console.log(`The result is ${await result.getText()}`);\n    \/\/ await browser.deleteSession()\n})().catch((e) => console.error(e))\n<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>By default, webdriverIO v6 will try to connect using devtools protocol unless an explicit WebDriver path is specified.<\/p>\n\n\n\n<p>To run the script just type:<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>node &lt;scriptname>.js\n<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"DevTools_Result\"><\/span>DevTools Result<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>The first thing you will notice when executing the script is this line of log:&nbsp;<code>INFO webdriverio: Initiate new session using the devtools protocol<\/code>&nbsp;which indicates the protocol used.<\/p>\n\n\n\n<p>And you&#8217;ll get this result:&nbsp;<em><strong>The result is 0.85<\/strong><\/em>. Which is really fast, meaning at least 50 browser interactions occurred in less than a second.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"WebDriver_Result\"><\/span>WebDriver Result<span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p>In order to execute the same script on WebDriver protocol, we need to specify the&nbsp;<code>hostname<\/code>&nbsp;and&nbsp;<code>path<\/code>&nbsp;when creating the remote object. We also require a running WebDriver server. I recommend installing the&nbsp;<a href=\"https:\/\/www.npmjs.com\/package\/webdriver-manager\">webdriver-manager<\/a>&nbsp;package which simplifies the process a lot.<\/p>\n\n\n\n<p>Once the WebDriver is running (by default it runs on localhost:444\/wd\/hub), then just update the code.<br><\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>...\n const browser = await remote({\n        logLevel: 'trace', capabilities: { browserName: 'chrome'},\n        hostname: 'localhost', path:'\/wd\/hub'\n    })\n...\n<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Again you will notice that the WebDriver protocol is specified:&nbsp;<code>INFO webdriverio: Initiate new session using the webdriver protocol<\/code>.<\/p>\n\n\n\n<p>And the result is:&nbsp;<em><strong>3.801<\/strong><\/em>&nbsp;which is impressive, but it&#8217;s four times slower than the first execution and puts WebDriver in second place.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Final_Thoughts\"><\/span>Final Thoughts<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We can easily conclude that the DevTools protocol executes scripts way faster which makes me consider it as a scripting and scraping tool. But there&#8217;s no free lunch, WebDriver is nowadays the most used interface and the one that has support for cross-browser testing, devices and even desktop apps.<\/p>\n\n\n\n<p>I&#8217;d also like to mention the great capability of webdriverIO to support both protocols out of the box. It really matters a lot when a tool allows you the power of choice.<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><em>Credits for the protocols images to the <a rel=\"noreferrer noopener\" aria-label=\"webdriverIO website (opens in a new tab)\" href=\"https:\/\/webdriver.io\/\" target=\"_blank\">webdriverIO website<\/a><\/em>. <em>This article was originally published <a rel=\"noreferrer noopener\" aria-label=\"here (opens in a new tab)\" href=\"https:\/\/dev.to\/pjcalvo\/webdriver-vs-chrome-devtools-speed-test-441h\" target=\"_blank\">here<\/a> on Dev.to<\/em><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"Recommended_for_You\"><\/span>Recommended for You<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><a href=\"https:\/\/abstracta.us\/blog\/tools\/12-top-test-automation-tools\/\">Top Test Automation Tools to Try in Your Next Project<\/a><br><a rel=\"noreferrer noopener\" aria-label=\"Migrating to Open Source Testing Tools (Especially Now) (opens in a new tab)\" href=\"https:\/\/abstracta.us\/blog\/software-testing\/migrating-to-open-source-testing-tools\/\" target=\"_blank\">Migrating to Open Source Testing Tools (Especially Now)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Comparing the two protocols to beat a fun automation game I was inspired recently by Federico Toledo to write a test script that can automate a simple clicking game, but with a focus on executing as fast as possible. Test automation challenge: Can you prepare&#8230;<\/p>\n","protected":false},"author":49,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[61],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v14.0.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WebDriver vs Chrome DevTools (Speed Test) | Abstracta<\/title>\n<meta name=\"description\" content=\"Putting them to the test: WebDriver vs Chrome DevTools... which one executes scripts faster? Pablo Calvo explains!\" \/>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WebDriver vs Chrome DevTools (Speed Test) | Abstracta\" \/>\n<meta property=\"og:description\" content=\"Putting them to the test: WebDriver vs Chrome DevTools... which one executes scripts faster? Pablo Calvo explains!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/AbstractaQA\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-07T22:16:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-05-05T21:22:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/abstracta.us\/wp-content\/uploads\/2020\/06\/Screen-Shot-2020-06-24-at-3.49.28-PM-min.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"866\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@AbstractaUS\" \/>\n<meta name=\"twitter:site\" content=\"@AbstractaUS\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/abstracta.us\/blog\/#website\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Blog about AI-powered quality engineering for teams building complex software | Abstracta\",\"description\":\"AI-powered quality engineering\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/abstracta.us\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/res.cloudinary.com\/practicaldev\/image\/fetch\/s--mgX314HT--\/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880\/https:\/\/dev-to-uploads.s3.amazonaws.com\/i\/z9vv3vqm71k2mlqb766l.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/#webpage\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/\",\"name\":\"WebDriver vs Chrome DevTools (Speed Test) | Abstracta\",\"isPartOf\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/#primaryimage\"},\"datePublished\":\"2020-07-07T22:16:00+00:00\",\"dateModified\":\"2025-05-05T21:22:44+00:00\",\"author\":{\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/f874369a1427ce165f787ec28705be78\"},\"description\":\"Putting them to the test: WebDriver vs Chrome DevTools... which one executes scripts faster? Pablo Calvo explains!\",\"breadcrumb\":{\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/\",\"url\":\"https:\/\/abstracta.us\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-tools\/\",\"name\":\"Testing Tools\"}},{\"@type\":\"ListItem\",\"position\":3,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/\",\"url\":\"https:\/\/abstracta.us\/blog\/testing-tools\/webdriver-vs-chrome-devtools-speed-test\/\",\"name\":\"WebDriver vs Chrome DevTools (Speed Test)\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/abstracta.us\/blog\/#\/schema\/person\/f874369a1427ce165f787ec28705be78\",\"name\":\"Pablo Calvo\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/abstracta.us\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/0e39546963e53aea036ff38773bdaadb?s=96&d=blank&r=g\",\"caption\":\"Pablo Calvo\"},\"description\":\"Read articles by Pablo Calvo for the Abstracta software testing blog here!\",\"sameAs\":[\"Posts by Pablo Calvo | Abstracta Blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/12994"}],"collection":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/users\/49"}],"replies":[{"embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/comments?post=12994"}],"version-history":[{"count":14,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/12994\/revisions"}],"predecessor-version":[{"id":13199,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/posts\/12994\/revisions\/13199"}],"wp:attachment":[{"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/media?parent=12994"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/categories?post=12994"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abstracta.us\/blog\/wp-json\/wp\/v2\/tags?post=12994"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}