fetch

fun fetch(): T

Resolves the matched component and returns it as the T the query named. This is the last resort, for a call that requires the matched component itself (e.g. a JTable's model, a JTree's selection) or for its identity. To read a value, use assertProperty, a matcher or an assertion. A query that named the type does not name it again:

val table = onNodeOfType<JTable>().fetch()

Throws

if the query has no single target.


@JvmName(name = "fetchOfType")
inline fun <R : Component> fetch(): R

Resolves the matched component and returns it typed as R, for a query that named no type of its own, or that named a wider one than the component to be driven. Like fetch, it is the last resort; assertProperty, a matcher or an assertion reads a value.

val save = onNodeWithText("Save").fetch<JButton>()
onNodeWithText("Reload").performClick()
assertSame(save, onNodeWithText("Save").fetch<JButton>())

Throws

if the query has no single target, or if the target is not an R.