Skip to content

Instantly share code, notes, and snippets.

@gunesmes
Created February 18, 2022 14:30
Show Gist options
  • Save gunesmes/6c59a4585d47e03b2aa76550424cdeb4 to your computer and use it in GitHub Desktop.
Save gunesmes/6c59a4585d47e03b2aa76550424cdeb4 to your computer and use it in GitHub Desktop.
package testrisk.dictionary.pages
import androidx.annotation.IdRes
import androidx.test.espresso.Espresso
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import testrisk.dictionary.R
import testrisk.dictionary.utils.Utility
open class BaseScreen : Utility() {
private val device: UiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val packageName: String = device.currentPackageName
open var baseElement: ViewInteraction? = Espresso.onView(withId(R.id.text))
companion object {
const val defaultLoadTime = 30000
const val defaultWaitTime = 10000
}
fun tapClose() {
device.findObject(UiSelector().textContains("Close")).click()
}
fun waitForPageLoading(@IdRes element: ViewInteraction? = baseElement) {
if (element != null) {
waitUntilElementVisible(element)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment