Last active
November 3, 2021 01:05
-
-
Save heitorpaceli/ff73ee646ea270376fcfc7fd89e2261d to your computer and use it in GitHub Desktop.
Validating Wi-Fi connection - UI Automator Medium article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
// 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