Skip to content

Mobile App Calls

Automated testing of Mobile App calls can be done on various versions of Android and iOS. Additionally, you can choose from a wide range of different devices to run your tests on. The test script is written in JavaScript and uses the CodeceptJs framework.

Info

For a full list of supported devices and OS versions, see this list.

Test Options

When creating/editing a Mobile app test, you can specify the following options:

  • CodeceptJs test script: The JavaScript code that describes the steps that the test will take.
  • Application platform: The platform of the application that the test will interact with (Android or iOS).
  • Application device: The device that the test will run on.
  • Application device OS version: The version of the OS that the test will run on.
  • Application image: Your app for Android or iOS that will be tested.
  • App-Store username: The username of the App Store account that will be used.
  • App-Store password: The password of the App Store account that will be used.
  • Store Artifacts: Whether to store the test artifacts such as audio recordings after the test run.
  • Calculate Audio MOS: Whether to calculate the Mean Opinion Score (MOS) for the audio quality of the call.
  • Transcribe Call Recording: Whether to transcribe the call recording to text.

Writing a CodeceptJs Test

The following is an example of a WebRTC test script that logs in and makes an outgoing call and hangs up after 30 seconds.

Feature('WebRTC Call');

Scenario("my-outgoing-call-scenario", async ({I}) => {
    I.amOnPage('/');            // Open the website root specified in the config

    // Login
    I.waitForElement("#username", 30);          // Wait for the inputs to appear
    I.fillField("#username", "my-username");    // Fill the username input
    I.fillField("#password", "my-password");    // Fill the password input
    I.click("#login-button");                   // Click the login button

    // Start a call
    I.waitForElement("#dialpad", 30);           // Wait for the dialpad to appear
    I.fillField("#dialpad", "+1-212-456-7890"); // Fill the number to call
    I.click("#call-button");                    // Click the call button

    I.wait(30);                                 // Wait for 30 seconds

    I.click("#hangup-button");                  // Click the hangup button
});

The provided test script is a simple example. You can extend it to include more complex scenarios, such as receiving a call, transferring a call, or any other scenario that a user could do on your Web app.

The script itself describes the steps that the test will take. The I object is the actor that performs the actions. The I object has a set of methods that you can use to interact with the browser, such as amOnPage, waitForElement, fillField, click, and wait. Step by step you select/locate the elements on the HTML page, fill in the fields, click the buttons, and this way you simulate the user's actions required to perform the desired call scenario.

On the other end of the call we setup according to your configuration a SIP, PSTN or WebRTC client that will act as the call receiver.

Locating Elements

Element can be found by CSS or XPath locators.

I.seeElement('~user');                      // element with accessibility id
I.seeElement('#user');                      // element with id on iOS
I.seeElement('#com.example.app:id/user');   // element with id on Android
// using XPath
I.seeElement('//android.widget.ScrollView/android.widget.LinearLayout');

Info

For more details on locating elements, see the CodeceptJS documentation.

List of Methods

The I object has a set of methods that you can use to interact with the mobile app. Here are some of the most common methods:

  • amOnPage(url): Open a page with the specified URL.
  • waitForElement(locator, timeout): Wait for an element to appear on the page.
  • fillField(locator, value): Fill a field with the specified value.
  • click(locator): Click on an element.
  • wait(seconds): Wait for the specified number of seconds.

Info

For a full list of methods, see the CodeceptJS documentation.

Custom Sipfront Methods

In addition to the standard CodeceptJS methods, Sipfront provides some additional methods that you can use in your test scripts:

  • playAudio(number): Injects an audio file into the call and starts playing it.
  • requestIncomingCall(): Requests an incoming call from the other agent if it is a SIP client.
  • waitForReady(users, timeout): Waits with a timeout for the specified user to become ready to proceed. Used in conjunction with notifyReady in mobile app to mobile app calls to synchronize the test scripts before starting a call.
  • notifyReady(user): Notifies the other user that you are ready to proceed with the test/call.
  • terminateApplication(): Terminates the application with the given package or bundle id. Equivalent to removing the app from the recent menu (backgrounding it).
  • closeApplication(): Closes the application, simulating the press of the home button. Supports only Android.
  • pressBackButton(): Simulates pressing the back button. Supports only Android.
  • pressHomeButton(): Simulates pressing the home button. Supports only Android.
  • pressRecentsButton(): Simulates pressing the recents (app switch) button. Supports only Android.

Info

Audio injection is limited to certain Android devices, see the list of supported devices.