Simulating SMS Messages and Phone Calls on Android while Automation


     Our mobile devices are, well, mobile! We can send and receive various kinds of communication through them, including text/SMS messages.  It is also possible to receive and interact with incoming phone calls! This might be relevant for apps that engage with the phone subsystem in some way, or it might just be a good idea to test that nothing goes wrong in your app when someone takes a call while using it.

Simulating SMS Messages:

       Sometimes, SMS messages might be an integral part of the user experience of our own apps. This is certainly true for messaging apps themselves, but you could imagine a variety of other applications that tie into the SMS world. How can we have Appium send a text message to the emulator so we can see the app verification behavior at work? The answer is to use the aptly-named sendSMS command:

driver.sendSMS(“555-555-5555”, “Your message here!”);


        And that’s really it. Simply supply the two String parameters (“from” phone number and message). Well, there is one more requirement for this whole scenario to work: you have to be testing on emulators, since the sendSMS command is not available for real devices. So to prove to Appium that we’re running an emulator and not a real device, it’s currently required to send in the avd capability with the name of the emulator you’re running the test on. If that emulator is already up and running, Appium will simply use it as is. If it’s not up and running, then Appium will start it for you. If you don’t provide this capability, Appium will complain when you try to use the sendSMS command that it only works on emulators.

Simulating Incoming Phone Calls:

       Of course, this only works on emulators; to achieve the same result on a real device, just make sure the real device has a working SIM card and trigger a call to it using one of the available phone call automation services.

     How can we take advantage of this feature? It’s made available in the Appium Java client via the driver.makeGsmCall() method. This method takes two parameters:

  • A string representing the phone number which the emulator will show as calling it (this should be purely numbers, no dashes or parentheses).
  • A member of the GsmCallActions enum, namely one of GsmCallActions.CALLGsmCallActions.CANCELGsmCallActions.ACCEPT, or GsmCallActions.HOLD. Each of these defines an action the emulator will take with respect to the particular phone number that has called.

Basically, to initiate a call to the emulator, we first make a call like this:

driver.makeGsmCall(“1234567890”, GsmCallActions.CALL);

This will start the device “ringing”. At this point it will continue to ring until we follow up with another action. We may, for example, choose to accept the call:

driver.makeGsmCall(“1234567890”, GsmCallActions.ACCEPT);

At this point the call will be active, and will remain active until we choose to end it:

driver.makeGsmCall(“1234567890”, GsmCallActions.CANCEL);

        Using this series of commands, we can simulate the entire flow of a user receiving a phone call while in our app, accepting the call, continuing to go about his/her business in the app while the call is active, and then ending the call. At any point in this flow we can continue to run regular Appium commands, which is how we would check that our app continues to function normally even as the call takes place.

        Please try to use above actions if required in your automation scripts. Recommend to use latest java-client 6.1.0

Reference: Appium Pro

make it perfect !


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at

Up ↑

%d bloggers like this: