I want to know is it possible to automate two application communicating each other. I'll explain my requirement with two examples just for you ti understand.

Example 1 - Let's take a taxi booking application. Passenger app will send a request to Driver app. Driver app is installed in driver's phone and Passenger app is installed in clients phone,
When Passenger app sends a request, driver app receives an alert, and then driver accepts the hire request. (driver must accept the request within 30 seconds)

Example 2 - A payment app,
Let's say there is a merchant app and customer app. When we enter some amount to the merchant app, it will generate a QR code, this code then will be scanned from customer app and the customer can pay with already saved, credit card.

While one app is running the other app should run, because if we close the first app, the current state of the app is lost. Since one app is waiting till the other app's response and based on the response the 1st app will continue the flow. So one app is waiting till other app's responds(ex: within 15 seconds driver app should response)

**How to simulate this using Appium, Java, Selenium to perform automation testing with the use of emulator or real device?**