I have a problem where the base (root) adapter reference for an Android app is NOT valid after the app is updated via some user action. This problem requires the base adapter to be found again after every user action. Also it's not clear how long to delay before the search operation as the base gets invalid after some time when the app eventually updates.
Is this a known problem? Has anybody got this working on a real mobile device?
The following example code shows the problem.
The app is deployed in an Android Emulator (adt-bundle-windows-x86-20130729, AVD_for_Nexus_S_by_Google).
The provided (IronPython) code example is using the Android APIDemos app.
Note that the same logic in C# has the same problem...
Code: Select all
import clr
clr.AddReference('Ranorex.Core')
clr.AddReference('Ranorex.Plugin.Mobile')
import time
from Ranorex.Core import RxPath
from Ranorex import MobileApp, AndroidApp, Text, Host
mobile_device = 'AA'
mobile_app = 'com.example.android.apis'
mobile_app_id = "/mobileapp[@title='com.example.android.apis']"
find_normal_delay = 30000
Host.Local.RunMobileApp(mobile_device, mobile_app)
app = Host.Local.Find[MobileApp](RxPath(mobile_app_id), find_normal_delay)[0]
assert(app.Valid, "Base app reference is NOT valid")
choice_id = "./form[@title='ApiDemos']/container/list/text[@caption='App']"
list_choice = app.Find[Text](RxPath(choice_id), find_normal_delay)[0]
assert(list_choice.Valid)
list_choice.Click()
time.sleep(10) # allow for the app to update
assert(app.Valid, "Base app reference is NOT valid")
choice_id = "./form[@title='ApiDemos']/container/list/text[@caption='Alarm']"
list_choice = app.Find[Text](RxPath(choice_id), find_normal_delay)[0]
assert(list_choice.Valid)
list_choice.Click()
time.sleep(10) # allow for the app to update
Host.Local.CloseApplication(app.Element)