Our goal is to enable you to focus on your core logic. Therefore, testRTC takes care of the script’s generic and infrastructure parts, such as the script’s initialization and objects creation.
You should focus only on the script logic to test your service.
In the test scripts we use functions and commands from the following groups:
- Nightwatch/Selenium commands – the Nightwatch/Selenium commands handle all browsing related actions, such as navigating to specific web pages, clicking on buttons and screen artifacts, filling in form fields, etc. Detailed Nightwatch/Selenium API reference can be found in http://nightwatchjs.org/api#commands
- testRTC functions – testRTC functions were implemented in order to help you debug your service. testRTC functions supports actions such as take a screen shot and create a log message. Check out or list of WebRTC-specific script commands
The client object that appear at the beginning of the script handles all Nightwatch/Selenium browsing related actions, such as navigating to specific web pages, clicking on buttons and screen artifacts, filling in form fields, etc.
All functions in the script return the client object and therefore a common method to scripts writing is chaining commands. When chaining commands, there is no need to add the semicolon symbol at the end of every command.
Code language: CSS (css)
client .url() .setValue() .rtcScreenshot() .click()
In general, most of the scripts will be based on the following flow:
- Navigate to the service web page
- If needed, enter some details (e.g. for video chat room, type user name and password to login)
- Click on a button to join a WebRTC session. At this point, the video call page should be loaded. As part of the video call page, the browser will be requested to stream the camera and microphone to the other parties in the call. When the camera and microphone streaming will be requested, testRTC will stream the selected video and audio media, instead the machine’s camera and microphone
- Consume media. Ensure to consume the media for enough time so testRTC system will be able to collect enough QoS information
- If needed, perform activities during the session, such as enter chat messages. In any case, we need to keep the test running for the requested time period. It can be done by using the pause command
- The total script duration will actually set the test’s total duration
- Test end / Session stop: While a WebRTC session is active, the browser collects statistical information that we will parse in order to present the test results, calculate test expectations, etc. If the browser will surf to a new URL, the browser will clear the WebRTC statistics and we will not be able to collect this information at the end of the test. Therefore please ensure that you will not surf to a new URL at the end of the WebRTC session
Note that in many implementations, terminating a session will redirect the browser to a new URL. In such cases, please refrain from terminating the session. The session will be killed after we will collect the data and we will delete the instance that executed the test. For further information, please see here.
Single script, multiple probes
In testRTC, each test is executed using a single test scripts that gets executed by multiple probes (=browsers) simultaneously.
For tests that are symmetric in nature, where all probes need to perform the same actions, this is great.
If you need to create asymmetric tests, where different probes run different logic (such as instructor/students or joining different rooms), then this can be achieved by using the environment variables. For example, variables such as process.env.RTC_IN_SESSION_ID along with if statements are quite useful in providing different flows for instructors and students joining the same room.