Hi!
I’m trying to build an Appium test suite for an Android application but I ran into a problem with the Android M’s permission model, specifically since the app asks for a permission straight at launch before the application itself starts up.
Now with the help of willosser’s reply in here, I am able to install the application so that it has all the permissions it needs, but for some reason after calling driver.startActivity() Appium will fail somewhat silently if I try to search for any elements and the Appium server log will print a following error message:
info: [debug] executing cmd: C:\Users\Tomi\Android_SDK\platform-tools\adb.exe shell “am start -S -n com.amaze.filemanager/.activities.MainActivity”
info: [debug] Responding to client with success: {“status”:0,“value”:“Successfully launched the app.”,“sessionId”:“8cdbf4b7-2ebc-4008-936e-dd8ba5acd883”}
info: ← POST /wd/hub/session/8cdbf4b7-2ebc-4008-936e-dd8ba5acd883/appium/device/start_activity 200 2615.435 ms - 104 {“status”:0,“value”:“Successfully launched the app.”,“sessionId”:“8cdbf4b7-2ebc-4008-936e-dd8ba5acd883”}
info: → POST /wd/hub/session/8cdbf4b7-2ebc-4008-936e-dd8ba5acd883/element {“using”:“xpath”,“value”:“//[@text=‘Alarms’]“}
info: [debug] Waiting up to 0ms for condition
info: [debug] Pushing command to appium work queue: [“find”,{“strategy”:“xpath”,“selector”:”//[@text=‘Alarms’]”,“context”:“”,“multiple”:false}]
error: Unhandled error: TypeError: Cannot read property ‘sendAction’ of null
at [object Object]. (C:\Program Files (x86)\Appium\node_modules\appium\lib\devices\android\android.js:504:23)
at Immediate.q.process [as _onImmediate] (C:\Program Files (x86)\Appium\node_modules\appium\node_modules\async\lib\async.js:806:21)
at processImmediate [as _immediateCallback] (timers.js:367:17) context: [POST /wd/hub/session/8cdbf4b7-2ebc-4008-936e-dd8ba5acd883/element {“using”:“xpath”,“value”:“//*[@text=‘Alarms’]”}]
It seems that the client is not sent an error message that the element could not be located, and overall seems the element is not waited for at all.
I tried to start the activity by just running driver.startActivity(package-name, activity-name) and by driver.startActivity(package-name, activity-name, package-name, activity-name) so Appium would wait for the activity to be actually started before starting the test set, but this seemed to not change anything.
My setUp method is following:
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(MobileCapabilityType.PLATFORM_NAME,"Android");
cap.setCapability(MobileCapabilityType.DEVICE_NAME, "Nexus 5x 1");
cap.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, "4000");
cap.setCapability(MobileCapabilityType.PLATFORM_VERSION, "6.0.1");
cap.setCapability("appPackage", "com.amaze.filemanager");
cap.setCapability("noReset", false);
cap.setCapability(MobileCapabilityType.FULL_RESET, false);
cap.setCapability("autoLaunch", false);
Runtime.getRuntime()
.exec("adb install -g C:\\Users\\Tomi\\Projects\\amazeFileManager\\AmazeFileManager\\build\\outputs\\apk\\AmazeFileManager-play-debug.apk");
driver = new AndroidDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), cap);
driver.startActivity("com.amaze.filemanager", "activities.MainActivity",
"com.amaze.filemanager", "activities.MainActivity");
and after that I attempted to put up a following wait:
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(
By.xpath("//*[@text='Alarms']"))
);
But that does not seem to do anything but get the error log on the server, after which everything stops. I am stumped on what to do.