Support & information center

AppRTC sample test script

AppRTC is Google’s original sample/demo for a peer-to-peer WebRTC implementation. In December 2021, Google decided to no longer support the hosted version of it and only offer it as a github repository.

In the past, we provided the AppRTC test script as a sample of using our service, but ever since the hosted version of it was removed from the internet, we had to remove it from our own samples.

If you are using it as your baseline, then the script below is a good starting point.


The script below creates random URL on AppRTC for the first probe joining the session, and then have the second probe joins the same random URL. You can use the script “as is” – just make sure the service URL points to your server.

Using the test script

In testRTC, create a new test script:

  1. Copy the code from the bottom of this article to your test script (or use the existing sample in your account)
  2. Decide the number of probes you want to use
    1. Concurrent probes will be good starting point – keep it at an even number (you need pairs of probes for this)
    2. Session size must be 2 for the AppRTC application to work properly
  3. Replace the Service URL of the script with the URL where your AppRTC signaling server is located

Test execution

Run the script. It does everything for you.

Test script code

    This example shows how to automate AppRTC scenarios in testRTC
    * Browser 1 goes to and creates a random room
    * Browser 1 sends room URL to browser 2
    * Browser 2 waits for room URL to arrive
    * Browser 2 joins the room
    * Both browsers run for 2 minutes
    To scale the test, change the number of concurrent users.
    You can't change the number of users per session, as AppRTC only
    allows 2 users in a room.
    * Probe configurations (look after the script):
      - Location of probes
      - Media files to use
      - Network configuration and quality
      - Browser version
    * Number of concurrent users (in a paid account. Evals limited to 2 max)
    * Service URL - trying VP9 and H264 instead of VP8
    We've decided to run AppRTC here with VP8 (look at the Service URL above).
    Just as easily, testRTC can support VP9, H.264 or any other codec and
    feature supported by the browser being used.

// Variables that we will use in this example
var agentType = Number(process.env.RTC_IN_SESSION_ID);
var sec = 1000;

// We set a few expectations. If these don't happen, the test will fail
// In AppRTC case, we want to make sure we have:
// 1. An incoming and outgoing audio and video channels
// 2. Media being sent on these channels
client.resizeWindow(1280, 720)
    .rtcSetTestExpectation(" == 1")
    .rtcSetTestExpectation("audio.out == 1")
    .rtcSetTestExpectation(" == 1")
    .rtcSetTestExpectation("video.out == 1")
    .rtcSetTestExpectation(" > 0")
    .rtcSetTestExpectation("audio.out.bitrate > 0")
    .rtcSetTestExpectation(" > 0")
    .rtcSetTestExpectation("video.out.bitrate > 0");

if (agentType === 1) {
    // Browser 1 actions take place here

    // Open initial AppRTC URL and join a randomly allocated room
	    .waitForElementVisible('body', 10*sec)
	    .waitForElementVisible('#join-button', 10*sec)
	    .waitForElementVisible('#videos', 30*sec)
	    .waitForElementVisible('#room-link', 30*sec)
	    .rtcScreenshot("Alone in call")
	    // Send the room URL to the second browser
    	.url(function (result) {
    		this.assert.equal(typeof result, "object");
    		this.assert.equal(result.status, 0);
    		var roomUrl = result.value;
    		this.assert.equal(!!roomUrl, true);
    		    .rtcInfo('Sending Room url %s', roomUrl)
        		.rtcProgress("Waiting @ " + roomUrl)
        		.rtcSetSessionValue("roomUrl", roomUrl);

} else {
    // Browser 2 actions take place here
    // Wait for Browser 1 to send us the URL for this call
    	.rtcWaitForSessionValue('roomUrl', function (urlToJoin) {
    		    .rtcInfo('Joining ', urlToJoin)
    		    .rtcProgress("Joining " + urlToJoin)
    		    .waitForElementVisible('body', 30*sec)
    		    .waitForElementVisible('#confirm-join-button', 30*sec)
    		    .waitForElementVisible('#videos', 30*sec);
    	}, 30*sec);

// Now that the browser is connected and in the room, we wait

    .rtcScreenshot("in call")

    .rtcProgress("Bye");Code language: JavaScript (javascript)

Was this article helpful?

Related Articles