in remote-robot/src/main/kotlin/com/intellij/remoterobot/SearchContext.kt [48:71]
fun <T : Fixture> find(type: Class<T>, locator: Locator, timeout: Duration): T {
val name = type.annotations.filterIsInstance<FixtureName>().firstOrNull()?.name ?: type.simpleName
return step("Search '$name' by '${locator.byDescription}'") {
var foundComponents: List<RemoteComponent> = emptyList()
waitFor(
timeout,
errorMessageSupplier = {
if (foundComponents.isEmpty()) {
"Failed to find '$name' by '${locator.byDescription}' in ${timeout.seconds}s"
} else {
"Found more than one '$name' by '${locator.byDescription}' in ${timeout.seconds}s. ${foundComponents.size} components found"
}
}
) {
foundComponents = finder.findMany(locator)
foundComponents.size == 1
}
val component = foundComponents.single()
return@step type.getConstructor(RemoteRobot::class.java, RemoteComponent::class.java)
.newInstance(_remoteRobot, component)
}
}