Skip to content

getNetworkConnection() always returning false irrespective of network connection enabled/ disabled. #78

@gsaimadhu

Description

@gsaimadhu

As part of my testing, the application under test sets the network connections, i have to test whether the connection settings are correctly set or not. So, i will be using getNetworkConnection() API in my testing, but this API always returning false.

Environment:

appium 1.2.0
Android 4.4.2
Java-client 1.5 and 1.6

Code snippet:

        try{
                NetworkConnectionSetting networkConnection = ((AppiumDriver) driver).getNetworkConnection();
                Boolean status = networkConnection.wifiEnabled();

                System.out.println("wifi status:" + status);//returning false
            } catch (Exception e){
                System.out.println(e);
            }

Discussed in appium discuss group. Appium server is returning 6 but java-client api always returning false irrespective of network connection enabled/ disabled.

Appium server logs:

Starting Node Server
info: Welcome to Appium v1.2.0 (REV e53f49c706a25242e66d36685c268b599cc18da5)
debug: Non-default server args: {"address":"127.0.0.1","logNoColors":true,"platformName":"Android","platformVersion":"18","automationName":"Appium"}
info: Appium REST http interface listener started on 127.0.0.1:4723
info: LogLevel: debug
info: --> POST /wd/hub/session {"desiredCapabilities":{"automationName":"Appium","newCommandTimeout":"6000","platformVersion":"4.3","app":"D://Desktop//MDM//GEN07112954E//GEN07112954E//Clients//Android//CAMDM.apk","deviceName":"mdmqa","platformName":"Android","browserName":"Android","appActivity":"com.Android.Afaria.Afaria","appium-version":"1.1.0.0","appPackage":"com.Android.CAMDM"}}
debug: Appium request initiated at /wd/hub/session
debug: Request received with params: {"desiredCapabilities":{"automationName":"Appium","newCommandTimeout":"6000","platformVersion":"4.3","app":"D://Desktop//MDM//GEN07112954E//GEN07112954E//Clients//Android//CAMDM.apk","deviceName":"mdmqa","platformName":"Android","browserName":"Android","appActivity":"com.Android.Afaria.Afaria","appium-version":"1.1.0.0","appPackage":"com.Android.CAMDM"}}
info: Starting android appium
debug: The following desired capabilities were provided, but not recognized by appium. They will be passed on to any other services running on this server. : appium-version
info: Retrieving device
debug: Using local app from desired caps: D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk
debug: Creating new appium session 7882163f-128e-4205-8323-7b9f9fc7dc60
debug: Using fast reset? true
debug: Preparing device for session
debug: Checking whether app is actually present
debug: Checking whether adb is present
debug: Using adb from D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe
debug: Trying to find a connected android device
debug: Getting connected devices...
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" devices
debug: 1 device(s) connected
info: Found device HC3C1MP00231
debug: Setting device id to HC3C1MP00231
debug: Waiting for device to be ready and to respond to shell commands (timeout = 5)
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 wait-for-device
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "echo 'ready'"
debug: Starting logcat capture
debug: Getting device API level
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "getprop ro.build.version.sdk"
debug: Device is at API Level 19
info: Device API level is: 19
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "getprop persist.sys.language"
debug: Current device language: en
debug: java -jar "D:\OpenTools\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk" "C:\Windows\Temp\com.Android.CAMDM" en
debug: No strings.xml for language 'en', getting default strings.xml
debug: java -jar "D:\OpenTools\Appium\node_modules\appium\node_modules\appium-adb\jars\strings_from_apk.jar" "D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk" "C:\Windows\Temp\com.Android.CAMDM"
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 push "C:\Windows\Temp\com.Android.CAMDM\strings.json" /data/local/tmp
debug: Checking whether aapt is present
debug: Using aapt from D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\build-tools\20.0.0\aapt.exe
debug: processFromManifest: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\build-tools\20.0.0\aapt.exe" dump xmltree "D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk" AndroidManifest.xml
debug: Set app process to: com.Android.CAMDM
debug: Not uninstalling app since server not started with --full-reset
debug: Checking app cert for D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk: java -jar "D:\OpenTools\Appium\node_modules\appium\node_modules\appium-adb\jars\verify.jar" "D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk"
debug: App already signed.
debug: Zip-aligning D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk
debug: Checking whether zipalign is present
debug: Using zipalign from D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\build-tools\20.0.0\zipalign.exe
debug: zipAlignApk: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\build-tools\20.0.0\zipalign.exe" -f 4 "D:\Desktop\MDM\GEN07112954E\GEN07112954E\Clients\Android\CAMDM.apk" "C:\Users\ganma05\AppData\Local\Temp\appium11475-10208-e6dvt6.tmp"
debug: MD5 for app is d45914b8c67c372f4e78a52f4b98abc2
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "ls /data/local/tmp/d45914b8c67c372f4e78a52f4b98abc2.apk"
debug: Getting install status for com.Android.CAMDM
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "pm list packages -3 com.Android.CAMDM"
debug: App is installed
info: App is already installed, resetting app
debug: Running fast reset (stop and clear)
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "am force-stop com.Android.CAMDM"
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "pm clear com.Android.CAMDM"
debug: Forwarding system:4724 to device:4724
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 forward tcp:4724 tcp:4724
debug: Pushing appium bootstrap to device...
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 push "D:\OpenTools\Appium\node_modules\appium\build\android_bootstrap\AppiumBootstrap.jar" /data/local/tmp/
debug: Pushing settings apk to device...
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 install "D:\OpenTools\Appium\node_modules\appium\build\settings_apk\settings_apk-debug.apk"
debug: Pushing unlock helper app to device...
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 install "D:\OpenTools\Appium\node_modules\appium\build\unlock_apk\unlock_apk-debug.apk"
info: Starting App
debug: Attempting to kill all 'uiautomator' processes
debug: Getting all processes with 'uiautomator'
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "ps 'uiautomator'"
debug: No matching processes found
debug: Running bootstrap
debug: spawning: D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe -s HC3C1MP00231 shell uiautomator runtest AppiumBootstrap.jar -c io.appium.android.bootstrap.Bootstrap
debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: numtests=1
debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: stream=
debug: [UIAUTOMATOR STDOUT] io.appium.android.bootstrap.Bootstrap:
debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: id=UiAutomatorTestRunner
debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: test=testRunServer
debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: class=io.appium.android.bootstrap.Bootstrap
debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS: current=1
debug: [UIAUTOMATOR STDOUT] INSTRUMENTATION_STATUS_CODE: 1
debug: [BOOTSTRAP] [debug] Socket opened on port 4724
debug: [BOOTSTRAP] [debug] Appium Socket Server Ready
debug: [BOOTSTRAP] [debug] Loading json...
debug: Waking up device if it's not alive
debug: Pushing command to appium work queue: ["wake",{}]
debug: [BOOTSTRAP] [debug] json loading complete.
debug: [BOOTSTRAP] [debug] Registered crash watchers.
debug: [BOOTSTRAP] [debug] Client connected
debug: [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"wake","params":{}}
debug: [BOOTSTRAP] [debug] Got command of type ACTION
debug: [BOOTSTRAP] [debug] Got command action: wake
debug: [BOOTSTRAP] [debug] Returning result: {"value":true,"status":0}
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "dumpsys window"
debug: Writing dumpsys output to D:\OpenTools\Appium\node_modules\appium.dumpsys.log
debug: Screen already unlocked, continuing.
debug: Pushing command to appium work queue: ["getDataDir",{}]
debug: [BOOTSTRAP] [debug] Got data from client: {"cmd":"action","action":"getDataDir","params":{}}
debug: [BOOTSTRAP] [debug] Got command of type ACTION
debug: [BOOTSTRAP] [debug] Got command action: getDataDir
debug: [BOOTSTRAP] [debug] Returning result: {"value":"/data/local/tmp","status":0}
debug: dataDir set to: /data/local/tmp
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "am start -S -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000 -n com.Android.CAMDM/com.Android.Afaria.Afaria"
debug: Waiting for pkg "com.Android.CAMDM" and activity "com.Android.Afaria.Afaria" to be focused
debug: Getting focused package and activity
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "dumpsys window windows"
debug: Device launched! Ready for commands
info: <-- POST /wd/hub/session 303 11786.192 ms - 9
debug: Setting command timeout to 6000 secs
debug: Appium session started with sessionId 7882163f-128e-4205-8323-7b9f9fc7dc60
info: --> GET /wd/hub/session/7882163f-128e-4205-8323-7b9f9fc7dc60 {}
debug: Appium request initiated at /wd/hub/session/7882163f-128e-4205-8323-7b9f9fc7dc60
info: <-- GET /wd/hub/session/7882163f-128e-4205-8323-7b9f9fc7dc60 200 1.625 ms - 878 {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.3","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"warnings":{},"desired":{"automationName":"Appium","newCommandTimeout":"6000","platformVersion":"4.3","app":"D://Desktop//MDM//GEN07112954E//GEN07112954E//Clients//Android//CAMDM.apk","deviceName":"mdmqa","platformName":"Android","browserName":"Android","appActivity":"com.Android.Afaria.Afaria","appium-version":"1.1.0.0","appPackage":"com.Android.CAMDM"},"automationName":"Appium","newCommandTimeout":"6000","app":"D://Desktop//MDM//GEN07112954E//GEN07112954E//Clients//Android//CAMDM.apk","deviceName":"mdmqa","platformName":"Android","appActivity":"com.Android.Afaria.Afaria","appium-version":"1.1.0.0","appPackage":"com.Android.CAMDM"},"sessionId":"7882163f-128e-4205-8323-7b9f9fc7dc60"}
debug: Request received with params: {}
debug: Responding to client with success: {"status":0,"value":{"platform":"LINUX","browserName":"Android","platformVersion":"4.3","webStorageEnabled":false,"takesScreenshot":true,"javascriptEnabled":true,"databaseEnabled":false,"warnings":{},"desired":{"automationName":"Appium","newCommandTimeout":"6000","platformVersion":"4.3","app":"D://Desktop//MDM//GEN07112954E//GEN07112954E//Clients//Android//CAMDM.apk","deviceName":"mdmqa","platformName":"Android","browserName":"Android","appActivity":"com.Android.Afaria.Afaria","appium-version":"1.1.0.0","appPackage":"com.Android.CAMDM"},"automationName":"Appium","newCommandTimeout":"6000","app":"D://Desktop//MDM//GEN07112954E//GEN07112954E//Clients//Android//CAMDM.apk","deviceName":"mdmqa","platformName":"Android","appActivity":"com.Android.Afaria.Afaria","appium-version":"1.1.0.0","appPackage":"com.Android.CAMDM"},"sessionId":"7882163f-128e-4205-8323-7b9f9fc7dc60"}
info: --> GET /wd/hub/session/7882163f-128e-4205-8323-7b9f9fc7dc60/network_connection {}
debug: Appium request initiated at /wd/hub/session/7882163f-128e-4205-8323-7b9f9fc7dc60/network_connection
info: Getting network connection
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "settings get global airplane_mode_on"
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "settings get global wifi_on"
debug: executing: "D:\Desktop\MDM\adt-bundle-windows-x86_64-20140321\sdk\platform-tools\adb.exe" -s HC3C1MP00231 shell "settings get global mobile_data"
debug: Responding to client with success: {"status":0,"value":6,"sessionId":"7882163f-128e-4205-8323-7b9f9fc7dc60"}
info: <-- GET /wd/hub/session/7882163f-128e-4205-8323-7b9f9fc7dc60/network_connection 200 3731.798 ms - 73 {"status":0,"value":6,"sessionId":"7882163f-128e-4205-8323-7b9f9fc7dc60"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions