1
votes
public class basic extends base{

    public static void main(String[] args) throws MalformedURLException {
        // TODO Auto-generated method stub

        AndroidDriver<AndroidElement>  driver=  Capabilities();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.findElementByXPath("//android.widget.TextView[@text='Preference']").click();
    }
}

This is my program. When I ran, only the application gets invoke but preference menu is not opening. Please refer below image.

Appium Preference

This is appium log

info: --> POST /wd/hub/session {"capabilities":[{"desiredCapabilities":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"}},{"requiredCapabilities":{}}],"desiredCapabilities":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"},"requiredCapabilities":{}} info: Client User-Agent string: Apache-HttpClient/4.5.3 (Java/1.8.0_131) info: [debug] No appActivity desired capability or server param. Parsing from apk. info: [debug] No appPackage desired capability or server param. Parsing from apk. info: [debug] Using local app from desired caps: C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk info: [debug] Creating new appium session 2ee7300a-fdaf-4b56-8b3f-17688e987e33 info: Starting android appium info: [debug] Getting Java version info: Java version is: 1.8.0_77 info: [debug] Checking whether adb is present info: [debug] Using adb from C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe info: [debug] Parsing package and activity from app manifest info: [debug] Checking whether aapt is present info: [debug] Using aapt from C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe info: [debug] Extracting package and launch activity from manifest. info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe dump badging C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk info: [debug] badging package: io.appium.android.apis info: [debug] badging act: io.appium.android.apis.ApiDemos info: [debug] Parsed package and activity are: io.appium.android.apis/io.appium.android.apis.ApiDemos info: [debug] Using fast reset? true info: [debug] Preparing device for session info: [debug] Checking whether app is actually present info: Retrieving device info: [debug] Trying to find a connected android device info: [debug] Getting connected devices... info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe devices info: [debug] 1 device(s) connected info: Found device 9b56dc7f0603 info: [debug] Setting device id to 9b56dc7f0603 info: [debug] Waiting for device to be ready and to respond to shell commands (timeout = 5) info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 wait-for-device info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "echo 'ready'" info: [debug] Starting logcat capture info: [debug] Getting device API level info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "getprop ro.build.version.sdk" info: [debug] Device is at API Level 23 info: Device API level is: 23 info: [debug] Extracting strings for language: default info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "getprop persist.sys.language" info: [debug] Current device persist.sys.language: info: [debug] java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\appium_apk_tools.jar" "stringsFromApk" "C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk" "C:\Users\Sachin\AppData\Local\Temp\io.appium.android.apis" info: [debug] Reading strings from converted strings.json info: [debug] Setting language to default info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 push "C:\Users\Sachin\AppData\Local\Temp\io.appium.android.apis\strings.json" /data/local/tmp info: [debug] Checking whether aapt is present info: [debug] Using aapt from C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe info: [debug] Retrieving process from manifest. info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\aapt.exe dump xmltree C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk AndroidManifest.xml info: [debug] Set app process to: io.appium.android.apis info: [debug] Not uninstalling app since server not started with --full-reset info: [debug] Checking app cert for C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk. info: [debug] executing cmd: java -jar "C:\Program Files (x86)\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk info: [debug] App already signed. info: [debug] Zip-aligning C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk info: [debug] Checking whether zipalign is present info: [debug] Using zipalign from C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\zipalign.exe info: [debug] Zip-aligning apk. info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\build-tools\25.0.2\zipalign.exe -f 4 C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk C:\Users\Sachin\AppData\Local\Temp\11756-5248-1j4mqt2\appium.tmp info: [debug] MD5 for app is 29649242b53e9a67ba855b067422713c info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "ls /data/local/tmp/29649242b53e9a67ba855b067422713c.apk" info: [debug] Getting install status for io.appium.android.apis info: [debug] Getting device API level info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "getprop ro.build.version.sdk" info: [debug] Device is at API Level 23 info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "pm list packages -3 io.appium.android.apis" info: [debug] App is installed info: App is already installed, resetting app info: [debug] Running fast reset (stop and clear) info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "am force-stop io.appium.android.apis" info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "pm clear io.appium.android.apis" info: [debug] Forwarding system:4724 to device:4724 info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 forward tcp:4724 tcp:4724 info: [debug] Pushing appium bootstrap to device... info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 push "C:\Program Files (x86)\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/ info: [debug] Pushing settings apk to device... info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 install "C:\Program Files (x86)\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk" info: [debug] Pushing unlock helper app to device... info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 install "C:\Program Files (x86)\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk" info: Starting App info: [debug] Attempting to kill all 'uiautomator' processes info: [debug] Getting all processes with 'uiautomator' info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "ps 'uiautomator'" info: [debug] No matching processes found info: [debug] Running bootstrap info: [debug] spawning: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap -e pkg io.appium.android.apis -e disableAndroidWatchers false info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1 info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream= info: [debug] [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap: info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1 info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1 info: [debug] [BOOTSTRAP] [debug] Socket opened on port 4724 info: [debug] [BOOTSTRAP] [debug] Appium Socket Server Ready info: [debug] [BOOTSTRAP] [debug] Loading json... info: [debug] [BOOTSTRAP] [debug] json loading complete. info: [debug] [BOOTSTRAP] [debug] Registered crash watchers. info: [debug] Waking up device if it's not alive info: [debug] Pushing command to appium work queue: ["wake",{}] info: [debug] [BOOTSTRAP] [debug] Client connected info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: wake info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true} info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "dumpsys window" info: [debug] Screen already unlocked, continuing. info: [debug] Pushing command to appium work queue: ["getDataDir",{}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: getDataDir info: [debug] dataDir set to: /data/local/tmp info: [debug] Pushing command to appium work queue: ["compressedLayoutHierarchy",{"compressLayout":false}] info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"/data/local/tmp"} info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"compressedLayoutHierarchy","params":{"compressLayout":false}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: compressedLayoutHierarchy info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":false} info: [debug] Getting device API level info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "getprop ro.build.version.sdk" info: [debug] Device is at API Level 23 info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n io.appium.android.apis/io.appium.android.apis.ApiDemos" info: [debug] Waiting for pkg "io.appium.android.apis" and activity "io.appium.android.apis.ApiDemos" to be focused info: [debug] Getting focused package and activity info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "dumpsys window windows" info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "getprop ro.build.version.release" info: [debug] Device is at release version 6.0.1 info: [debug] Device launched! Ready for commands info: [debug] Setting command timeout to the default of 60 secs info: [debug] Appium session started with sessionId 2ee7300a-fdaf-4b56-8b3f-17688e987e33 info: <-- POST /wd/hub/session 303 23206.481 ms - 74 info: --> GET /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33 {} info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"},"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"9b56dc7f0603"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: <-- GET /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33 200 10.415 ms - 573 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"},"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"9b56dc7f0603"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: --> GET /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33 {} info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"},"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"9b56dc7f0603"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: <-- GET /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33 200 3.540 ms - 573 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"},"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"9b56dc7f0603"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: --> GET /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33 {} info: [debug] Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"},"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"9b56dc7f0603"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: <-- GET /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33 200 2.099 ms - 573 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"6.0.1","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"networkConnectionEnabled":true,"locationContextEnabled":false,"warnings":{},"desired":{"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"sachin"},"app":"C:\Users\Sachin\workspace\Practise\src\ApiDemos-debug.apk","platformName":"Android","deviceName":"9b56dc7f0603"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: --> POST /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33/timeouts {"type":"implicit","ms":10000} info: [debug] Set Android implicit wait to 10000ms info: [debug] Responding to client with success: {"status":0,"value":null,"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: <-- POST /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33/timeouts 200 9.747 ms - 76 {"status":0,"value":null,"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: --> POST /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33/element {"using":"xpath","value":"//android.widget.TextView[@text='Preference']"} info: [debug] Waiting up to 10000ms for condition info: [debug] Pushing command to appium work queue: ["find",{"strategy":"xpath","selector":"//android.widget.TextView[@text='Preference']","context":"","multiple":false}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"find","params":{"strategy":"xpath","selector":"//android.widget.TextView[@text='Preference']","context":"","multiple":false}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: find info: [debug] [BOOTSTRAP] [debug] Finding //android.widget.TextView[@text='Preference'] using XPATH with the contextId: multiple: false info: [debug] [BOOTSTRAP] [debug] Using: UiSelector[CLASS=android.widget.TextView, INSTANCE=9] info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":{"ELEMENT":"1"}} info: [debug] Responding to client with success: {"status":0,"value":{"ELEMENT":"1"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: <-- POST /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33/element 200 169.685 ms - 87 {"status":0,"value":{"ELEMENT":"1"},"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: --> POST /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33/element/1/click {"id":"1"} info: [debug] Pushing command to appium work queue: ["element:click",{"elementId":"1"}] info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"element:click","params":{"elementId":"1"}} info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION info: [debug] [BOOTSTRAP] [debug] Got command action: click info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":true} info: [debug] Responding to client with success: {"status":0,"value":true,"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: <-- POST /wd/hub/session/2ee7300a-fdaf-4b56-8b3f-17688e987e33/element/1/click 200 23.573 ms - 76 {"status":0,"value":true,"sessionId":"2ee7300a-fdaf-4b56-8b3f-17688e987e33"} info: [debug] Didn't get a new command in 60 secs, shutting down... info: Shutting down appium session info: [debug] Pressing the HOME button info: [debug] executing cmd: C:\Users\Sachin\AppData\Local\Android\sdk\platform-tools\adb.exe -s 9b56dc7f0603 shell "input keyevent 3" info: [debug] Stopping logcat capture info: [debug] Logcat terminated with code null, signal SIGTERM info: [debug] Sent shutdown command, waiting for UiAutomator to stop... info: [debug] [BOOTSTRAP] [debug] Got data from client: {"cmd":"shutdown"} info: [debug] [BOOTSTRAP] [debug] Got command of type SHUTDOWN info: [debug] [BOOTSTRAP] [debug] Returning result: {"status":0,"value":"OK, shutting down"} info: [debug] [BOOTSTRAP] [debug] Closed client connection info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1 info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=. info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1 info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 0 info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream= info: [debug] [UIAUTOMATOR STDOUT] Test results for WatcherResultPrinter=. info: [debug] [UIAUTOMATOR STDOUT] Time: 63.96 info: [debug] [UIAUTOMATOR STDOUT] OK (1 test) info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: -1 info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: shortMsg=java.lang.SecurityException info: [debug] [UIAUTOMATOR STDOUT] INSTRUMENTATION_RESULT: longMsg=Permission Denial: getIntentSender() from pid=32374, uid=2000, (need uid=1000) is not allowed to send as package android

1
Hi, @Sachin Kumar, Did u get any resolution for the problemDtestA

1 Answers

0
votes

You can click on the link by using below line of code:

driver.findElementByAccessibityID("Preference").click();