appium / dotnet-client

Extension to the official Selenium dotnet webdriver
Apache License 2.0
381 stars 187 forks source link

[Appium.WebDriver.5.0.0-rc.5]: Toggle wifi functionality not working/ "setConnectivity" "getConnectivity" not supported in .net client even though you could execute via appium inspector #745

Closed HarshdeepSingh3009 closed 7 months ago

HarshdeepSingh3009 commented 7 months ago

Description

Unable to toggle wifi using AndroidDriver.ToggleWifi() in rc 5. Did not try with previous versions. Also, I can disable, enable wifi using appium inspector execute command script but .net client does not allow using the command.

In appium inspector, one could use mobile: setConnectivity to set wifi status but if I use rc5 .net client, it throws following exception

Unknown mobile command "setConnectivity". Only shell,execEmuConsoleCommand,dragGesture,flingGesture,doubleClickGesture,clickGesture,longClickGesture,pinchCloseGesture,pinchOpenGesture,swipeGesture,scrollGesture,scrollBackTo,scroll,viewportScreenshot,viewportRect,deepLink,startLogsBroadcast,stopLogsBroadcast,acceptAlert,dismissAlert,batteryInfo,deviceInfo,getDeviceTime,changePermissions,getPermissions,performEditorAction,startScreenStreaming,stopScreenStreaming,getNotifications,listSms,type,sensorSet,pushFile,pullFile,pullFolder,deleteFile,isAppInstalled,queryAppState,activateApp,removeApp,terminateApp,installApp,clearApp,startActivity,startService,stopService,broadcast,getContexts,installMultipleApks,unlock,refreshGpsCache,startMediaProjectionRecording,isMediaProjectionRecordingRunning,stopMediaProjectionRecording commands are supported.

Could you add support for this string ? I think if I can do this via appium inspector I should be able to do it via code as well.

Environment

Details

Please provide more details, if necessary.

When I use AndroidDriver.ToggleWifi, it doe snot do anything, No exception is thrown but it does not toggle the wifi as well.

Code To Reproduce Issue [ Good To Have ]

Exception stack traces

System.NotImplementedException HResult=0x80004001 Message=Unknown mobile command "setConnectivity". Only shell,execEmuConsoleCommand,dragGesture,flingGesture,doubleClickGesture,clickGesture,longClickGesture,pinchCloseGesture,pinchOpenGesture,swipeGesture,scrollGesture,scrollBackTo,scroll,viewportScreenshot,viewportRect,deepLink,startLogsBroadcast,stopLogsBroadcast,acceptAlert,dismissAlert,batteryInfo,deviceInfo,getDeviceTime,changePermissions,getPermissions,performEditorAction,startScreenStreaming,stopScreenStreaming,getNotifications,listSms,type,sensorSet,pushFile,pullFile,pullFolder,deleteFile,isAppInstalled,queryAppState,activateApp,removeApp,terminateApp,installApp,clearApp,startActivity,startService,stopService,broadcast,getContexts,installMultipleApks,unlock,refreshGpsCache,startMediaProjectionRecording,isMediaProjectionRecordingRunning,stopMediaProjectionRecording commands are supported. Source=WebDriver StackTrace: at OpenQA.Selenium.WebDriver.UnpackAndThrowOnError(Response errorResponse, String commandToExecute) at OpenQA.Selenium.WebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Appium.AppiumDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.WebDriver.ExecuteScriptCommand(String script, String commandName, Object[] args) at OpenQA.Selenium.WebDriver.ExecuteScript(String script, Object[] args)

Link to Appium logs

Please create a gist which is a paste of your full Appium logs, and link them here. Do not paste your full Appium logs here, as it will make this issue very long and hard to read! If you are reporting a bug, always include Appium logs as linked gists! It helps to define the problem correctly and clearly.

jlipps commented 7 months ago

Are you sure this message is from the client and not the server? If you link to your Appium logs it will be more clear.

HarshdeepSingh3009 commented 7 months ago

2024-02-29 02:48:36:425 [AndroidUiautomator2Driver@6a5b (415b5b17)] Command 'toggleWiFi' has been deprecated and will be removed in a future version of Appium or your driver/plugin. Please use a different method or contact the driver/plugin author to add explicit support for the command before it is removed 2024-02-29 02:48:36:425 [AndroidUiautomator2Driver@6a5b (415b5b17)] Calling AppiumDriver.toggleWiFi() with args: ["415b5b17-22c7-4e14-89b2-d0d670628696"] 2024-02-29 02:48:36:425 [ADB] Running 'C:\AndroidSDK\platform-tools\adb.exe -P 5037 -s shell settings get global wifi_on' 2024-02-29 02:48:36:485 [AndroidUiautomator2Driver@6a5b (415b5b17)] Turning WiFi off 2024-02-29 02:48:36:486 [ADB] Running 'C:\AndroidSDK\platform-tools\adb.exe -P 5037 -s shell am broadcast -a io.appium.settings.wifi -n io.appium.settings/.receivers.WiFiConnectionSettingReceiver --es setstatus disable' 2024-02-29 02:48:36:558 [AndroidUiautomator2Driver@6a5b (415b5b17)] Responding to client with driver.toggleWiFi() result: null 2024-02-29 02:48:36:559 [HTTP] <-- POST /session/415b5b17-22c7-4e14-89b2-d0d670628696/appium/device/toggle_wifi 200 136 ms - 14


Then I try to get device Info, and it still shows wifi is connected "networks":[{"capabilities":{"SSID":null,"linkDownBandwidthKbps":64406,"linkUpstreamBandwidthKbps":12000,"networkCapabilities":"NET_CAPABILITY_NOT_METERED,NET_CAPABILITY_INTERNET,NET_CAPABILITY_NOT_RESTRICTED,NET_CAPABILITY_TRUSTED,NET_CAPABILITY_NOT_VPN,NET_CAPABILITY_VALIDATED,NET_CAPABILITY_NOT_ROAMING,NET_CAPABILITY_FOREGROUND,NET_CAPABILITY_NOT_CONGESTED,NET_CAPABILITY_NOT_SUSPENDED","signalStrength":-40,"transportTypes":"TRANSPORT_WIFI"},"detailedState":"CONNECTED","extraInfo":"","isAvailable":true,"isConnected":true,"isFailover":false,"isRoaming":false,"state":"CONNECTED","subtype":-1,"subtypeName":"","type":1,"typeName":"WIFI"}],"platformVersion":"14","


These are the logs when I execute togglewifi via dotnet client. Does this mean a new implementation of togglewifi is needed how about allowing use of "getConnectivity" and "setConnectivity" via executescript ?

[AndroidUiautomator2Driver@082e (385ae396)] Encountered internal error running command: UnknownCommandError: Unknown mobile command "getConnectivity". Only shell,execEmuConsoleCommand,dragGesture,flingGesture,doubleClickGesture,clickGesture,longClickGesture,pinchCloseGesture,pinchOpenGesture,swipeGesture,scrollGesture,scrollBackTo,scroll,viewportScreenshot,viewportRect,deepLink,startLogsBroadcast,stopLogsBroadcast,acceptAlert,dismissAlert,batteryInfo,deviceInfo,getDeviceTime,changePermissions,getPermissions,performEditorAction,startScreenStreaming,stopScreenStreaming,getNotifications,listSms,type,sensorSet,pushFile,pullFile,pullFolder,deleteFile,isAppInstalled,queryAppState,activateApp,removeApp,terminateApp,installApp,clearApp,startActivity,startService,stopService,broadcast,getContexts,installMultipleApks,unlock,refreshGpsCache,startMediaProjectionRecording,isMediaProjectionRecordingRunning,stopMediaProjectionRecording commands are supported. 2024-02-29 03:24:16:359 [AndroidUiautomator2Driver@082e (385ae396)] at AndroidUiautomator2Driver.executeMobile (C:\Users\SupportUser.appium\node_modules\appium-uiautomator2-driver\lib\commands\general.js:190:11) 2024-02-29 03:24:16:359 [AndroidUiautomator2Driver@082e (385ae396)] at AndroidUiautomator2Driver.execute (C:\Users\SupportUser.appium\node_modules\appium-uiautomator2-driver\node_modules\appium-android-driver\lib\commands

I assume this is a driver issue ? as per logs driver is telling that the command is not known. Even though the driver docs say it is : https://github.com/appium/appium-uiautomator2-driver/tree/v3.0.1?tab=readme-ov-file#mobile-getconnectivity

HarshdeepSingh3009 commented 7 months ago

This issue is resolved, Appium driver version being used was old, updated it to latest and it is working.. closing the issue. Thanks !