Skip to content

Instantly share code, notes, and snippets.

@heitorpaceli
Last active November 3, 2021 01:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save heitorpaceli/ff73ee646ea270376fcfc7fd89e2261d to your computer and use it in GitHub Desktop.
Save heitorpaceli/ff73ee646ea270376fcfc7fd89e2261d to your computer and use it in GitHub Desktop.
Validating Wi-Fi connection - UI Automator Medium article
// ...
// BySelector matching the just added Wi-Fi
val ssidSelector = By.text(ssid).res("android:id/title")
// BySelector matching the connected status
val status = By.text("Connected").res("android:id/summary")
// BySelector matching on entry of Wi-Fi list with the desired SSID and status
val networkEntrySelector = By.clazz(RelativeLayout::class.qualifiedName)
.hasChild(ssidSelector)
.hasChild(status)
// Perform the validation using hasObject
// Wait up to 5 seconds to find the element we're looking for
val isConnected = device.wait(Until.hasObject(networkEntrySelector), 5000)
Assert.assertTrue("Verify if device is connected to added Wi-Fi", isConnected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment