Appium driver loses focus on the app after sending push notification on Android 7

The problem

Unable to find the elements on the app using driver.findElement(xpath) after sending/receiving push notification on Android 7 platform.


Language used for writing automation scripts: Java
Android version that exhibits the issue: Android 7.0 (API 24), Android 7.1.1 (API 25)
Last Android version that did not exhibit the issue: Android 6 (API 23)
Appium version that exhibits the issue: 1.6.3
Desktop OS/version used to run Appium: Windows 7
Node.js version: V6.10.0 LTS
Real device or emulator/simulator: Nexus 5 Emulator (API 25) and Google Nexus 6 Device (API 24)


Steps to reproduce:

Launch the app on emulator / device:
o App launches successfully.

Find elements on the app using driver.findElement(xpath) and perform operations like isVisible(), click(), sendKeys() etc.:
o Works perfectly fine.

Trigger a push notification and wait for 5 seconds:
o Push notification appears on the notification panel and waits for 5 seconds.

Now try finding elements on the app using driver.findElement(xpath):
o Appium hangs and does not find the element.

NOTE: I am able to view the push notification from notification panel using driver.openNotifications() and also click the notification. But unable to perform any operation on the app. Everything works fine on Android 6 platform with Appium 1.6.3 version.

Link to Appium logs

Small portion of Appium logs. Here ‘pushio-dev’ is the title of the app which is visible and I am trying to find it.
[debug] [AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“find”,“params”: {“strategy”:“xpath”,“selector”:"//android.widget.TextView[@text=‘pushio-dev’]",“context”:"",“multiple”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“find”,“params”:
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: find
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Finding ‘//android.widget.TextView[@text=‘pushio-dev’]’ using ‘XPATH’ with the contextId: ‘’ multiple: false

Line of code failure

driver fails to identify the element even though it is present and visible in the emulator/ device.

Any help will be appreciated !