Performance Comparison: Selenium Ruby, Python, and JavaScript (Node.js)
The result: language differences are minor.
Selenium WebDriver comes with 5 official programming languages: Ruby, Java, Python, JavaScript and C#. My Selenium WebDriver Recipes books cover all five languages.
When there are choices, comparisons follow. Which Selenium language binding is the fastest? First of all, based on the Selenium WebDriver architecture, the difference will be small. The majority of test execution time resides on the driver (native) driving the browser (on the right side).
Still, there will be differences. For my benchmark tests, I selected 81 simple tests (from my recipe books) such as clicking a radio button by name or ID and asserting page text. The test scripts are written in the same way for all languages. I excluded Java and C# here because I seldom use them for automated testing (I professionally coded for 10+ years in Java and 3 years in C#), simply because they are not scripting languages.
Execution: set up 3 build projects in BuildWise, trigger several runs (as shown in the video below), and then take the average timing.
The results (in seconds) => Ruby: 27; Python: 31; Node.js: 24.
Translate to percentages: Ruby is 12% faster than Python and Node.js is 11% faster than Ruby. In terms of raw speed, Node.js is the winner.
However, raw speed is just a minor factor in UI test automation. Other factors include: easy to read, easy to maintain, flexible to use third-party libraries, …, etc. For me, Ruby is the best choice (see the reasons here).
Utilizing a Continuous Testing Server, such as BuildWise, can dramatically reduce the overall test execution time. For example, in my own test lab, I used 8 BuildWise agents to execute 600 Selenium user-story tests for ClinicWise project: cutting execution time from 4 hours to 39 minutes, a saving of 84%. I could simply add some build machines to cut the feedback time down further.
This article was initially published on LinkedIn on 2018–11–26.