We get asked how to create fake participants in a call fairly often. It’s on par with herding cats to coordinate three real-live human devs to each open four Chrome tabs to simulate twelve call participants. “Oh, wait, this test is running on localhost, let me set up an ngrok tunnel… 10 min later ok, try now. Oh, now Vanessa is at lunch. Great, we’ll pick it back up when she’s back.” Three hours later, you have almost confirmed half of your app works with six participants, if all participants are on your machine. This is where Robots (our affectionate name for automated WebDriver instances) step in and save the day, or at the very least, a non-trivial number of hours.
The W3C working draft spec defines WebDriver as “a remote control interface that enables introspection and control of user agents.” a.k.a. a Robot. Most browsers implement this spec, with chromedriver, safaridriver, and geckodriver (Firefox) being the most common examples. There are quite a few libraries and frameworks out there leveraging these drivers to automate browsers for testing, fun, and profit.
This post will go over how to spin up WebRTC-friendly headless Chromium instances, locally or in “the cloud”, to create fake participants. Skip to the But I want to use Node section for a Selenium example (implemented in, you guessed it, NodeJS).
Just the facts, ma’am
If testing in Chrome is all you need and you are CLI inclined, here’s the TL;DR:
The accepted video format is a bit arcane, so feel free to use the daily.y4m file found here if your ffmpeg skills are a bit rusty. Any .wav file will do for audio. If these are not passed in, Chrome’s green pac-man and boop boop audio are used.
Head(less) in the cloud(s)
For extra credit you can dream big and build off of the above by creating an AMI that runs Chromium on EC2 instances. This can be achieved, step by step, like so
Fret not, here is the gist of the basic chromedriver-using-selenium-webdriver-npm-module setup. This includes the custom fake media video file and requires the ChromeDriver program, which can be found here.
Gotcha 1: Chrome and ChromeDriver’s versions must match. You'll see the error SessionNotCreatedError: session not created: This version of ChromeDriver only supports Chrome version __ otherwise. Protip 1: Check your version of Chrome via chrome://version and download the corresponding driver.
Gotcha 2: “Help! I spun up a bunch of headless robots and they have taken over my machine.” It is true that browser instances without heads are a bit more difficult to catch and kill. Protip 2: This one liner will find and kill all WebRTC-friendly ChromeDriver processes and return CPU usage to its rightful owner: the GUI Chrome instance.🙃
There are many ways to automate all the things(™) and these are just a few ways to start. After things run smoothly with chromedriver, try leveling up by using geckodriver and safaridriver with selenium-webdriver. Extra points are awarded to those who run multiple different WebDrivers at the same time.