toggleWifi() is not working with Espresso driver

Hi,

When i try to toggleWifi using espresso driver i get the following error

[debug] e[35m[WD Proxy]e[39m Matched ‘/wd/hub/session/752cdd19-98ce-44c7-8063-8fa3e0fd0571/appium/device/toggle_wifi’ to command name ‘toggleWiFi’
[debug] e[35m[WD Proxy]e[39m Proxying [POST /wd/hub/session/752cdd19-98ce-44c7-8063-8fa3e0fd0571/appium/device/toggle_wifi] to [POST http://localhost:8306/session/451ca417-0fbd-463c-bf24-09a3f9b5bf1f/appium/device/toggle_wifi] with body: {}
e[35m[WD Proxy]e[39m Got an unexpected response with status 500: {“id”:“379f6855-b7ca-4b7f-9a54-05b2cb35a9c9”,“sessionId”:null,“value”:{“error”:“unknown error”,“message”:“No such route: /session/451ca417-0fbd-463c-bf24-09a3f9b5bf1f/appium/device/toggle_wifi”,“stacktrace”:“io.appium.espressoserver.lib.handlers.exceptions.AppiumException: No such route: /session/451ca417-0fbd-463c-bf24-09a3f9b5bf1f/appium/device/toggle_wifi\n\tat io.appium.espressoserver.lib.http.Router.route(Router.kt:180)\n\tat io.appium.espressoserver.lib.http.Server.serve(Server.kt:49)\n\tat fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)\n\tat fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)\n\tat java.lang.Thread.run(Thread.java:762)\n”}}
[debug] e[35m[W3C (752cdd19)]e[39m Encountered internal error running command: ProxyRequestError: Could not proxy command to remote server. Original error: 500 - {“id”:“379f6855-b7ca-4b7f-9a54-05b2cb35a9c9”,“sessionId”:null,“value”:{“error”:“unknown error”,“message”:“No such route: /session/451ca417-0fbd-463c-bf24-09a3f9b5bf1f/appium/device/toggle_wifi”,“stacktrace”:“io.appium.espressoserver.lib.handlers.exceptions.AppiumException: No such route: /session/451ca417-0fbd-463c-bf24-09a3f9b5bf1f/appium/device/toggle_wifi\n\tat io.appium.espressoserver.lib.http.Router.route(Router.kt:180)\n\tat io.appium.espressoserver.lib.http.Server.serve(Server.kt:49)\n\tat fi.iki.elonen.NanoHTTPD$HTTPSession.execute(NanoHTTPD.java:945)\n\tat fi.iki.elonen.NanoHTTPD$ClientHandler.run(NanoHTTPD.java:192)\n\tat java.lang.Thread.run(Thread.java:762)\n”}}
[debug] e[35m[W3C (752cdd19)]e[39m at JWProxy.proxy (C:\Users\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\jsonwp-proxy\proxy.js:213:13)
[debug] e[35m[W3C]e[39m Matched W3C error code ‘unknown error’ to UnknownError
e[35m[HTTP]e[39m e[37m<-- POST /wd/hub/session/752cdd19-98ce-44c7-8063-8fa3e0fd0571/appium/device/toggle_wifi e[39me[31m500e[39m e[90m29 ms - 705e[39m
e[35m[HTTP]e[39m e[90me[39m

In Appium document http://appium.io/docs/en/commands/device/network/toggle-wifi/ i see that espresso supports this feature but i am facing error. Can someone help me out?

@mykola-mokhnach any suggestions?

Thanks,
Shreeja

It is impossible to implement such functionality with Espresso, since wifi disconnection would immediately terminate the connection to Espresso driver itself and would render it to an undefined state.

Thanks @mykola-mokhnach. So this means even closeapp or terminateapp cannot be implemented using espresso? It would simple terminate the session am i right?

Correct. Espresso stuff is actually injected into the application under test. So as soon as the application stops working the connection to this server is terminated as well.