title: How to test wifi connection via adb?
body: <p>Im automating wifi off/on via adb.</p>
  
  <p>I would either like to disable/enable wifi based on the test case</p>
  
  <p>so far I have found good information <a href="https://stackoverflow.com/questions/10033757/how-to-turn-off-wifi-via-adb">here</a></p>
  
  <p>However I want to test the connection before executing following command</p>
  
  <pre><code>adb shell am start -a android.intent.action.MAIN -n         com.android.settings/.wifi.WifiSettings adb shell input keyevent 19 &amp; adb shell input keyevent 19 &amp; adb shell input keyevent 23
  </code></pre>
  
  <p>Above command disables wifi if enabled, enables wifi if disabled. I want to first test the connection and take action if required. I am wondering if there is a way to do using adb command. This can be achieved programatically but I want it to be done through adb for making it more reliable.</p>
  
  <p>Also following command works only if device is rooted</p>
  
  <pre><code>adb shell "svc wifi enable" 
  </code></pre>
  
  <p>Also following command launches test on screen but provides no info via adb</p>
  
  <pre><code>adb shell am start -n com.android.settings/.wifi.WifiStatusTest
  </code></pre>