@@ -29,16 +29,16 @@ import io.appium.espressoserver.lib.model.EspressoElement
29
29
import io.appium.espressoserver.lib.model.web.WebAtomsParams
30
30
import io.appium.espressoserver.lib.viewmatcher.withView
31
31
32
- class WebAtoms : RequestHandler <WebAtomsParams , Void ?> {
32
+ class WebAtoms : RequestHandler <WebAtomsParams , Any ?> {
33
33
34
34
@Throws(AppiumException ::class )
35
- override fun handleInternal (params : WebAtomsParams ): Void ? {
36
- var webViewInteraction: WebInteraction <* >
35
+ override fun handleInternal (params : WebAtomsParams ): Any ? {
36
+ var webViewInteraction: WebInteraction <* >
37
37
38
38
// TODO: Add a 'waitForDocument' feature to wait for HTML DOCUMENT to be ready
39
39
40
40
// Initialize onWebView with web view matcher (if webviewEl provided)
41
- params.webviewElement.let { webviewElement ->
41
+ params.webviewElement.let { webviewElement ->
42
42
AndroidLogger .info(" Initializing webView interaction on webview with el: '$webviewElement '" )
43
43
val viewState = EspressoElement .getCachedViewStateById(webviewElement)
44
44
val matcher = withView(viewState.view)
@@ -53,18 +53,22 @@ class WebAtoms : RequestHandler<WebAtomsParams, Void?> {
53
53
// Iterate through methodsChain and call the atoms
54
54
params.methodChain.forEach { method ->
55
55
val atom = invokeStaticMethod(DriverAtoms ::class .java, method.atom.name, * method.atom.args) as ? Atom <* >
56
- ? : throw InvalidArgumentException (" '${method.atom.name} ' did not return a valid " +
57
- " '${Atom ::class .qualifiedName} ' object" )
56
+ ? : throw InvalidArgumentException (
57
+ " '${method.atom.name} ' did not return a valid '${Atom ::class .qualifiedName} ' object" ,
58
+ )
58
59
59
60
AndroidLogger .info(" Calling interaction '${method.name} ' with the atom '${method.atom} '" )
60
61
61
62
val res = invokeInstanceMethod(webViewInteraction, method.name, atom) as ? WebInteraction <* >
62
- ? : throw InvalidArgumentException (" '${method.name} ' does not return a valid " +
63
- " '${WebInteraction ::class .qualifiedName} ' object" )
63
+ ? : throw InvalidArgumentException (
64
+ " '${method.name} ' does not return a valid '${WebInteraction ::class .qualifiedName} ' object" ,
65
+ )
64
66
65
67
webViewInteraction = res
66
68
}
67
-
68
- return null
69
+ // if you don't pass any action to perform `webViewInteraction.get()` will throw error
70
+ // java.lang.IllegalStateException: Perform or Check never called on this WebInteraction!
71
+ // when you just want to just check element existence call with `selectActiveElement` as action
72
+ return webViewInteraction.get()
69
73
}
70
74
}
0 commit comments