public class JavaScriptMethodInterceptor extends Object
JavaScript,
JavaScriptFunction,
ManualJavaScriptInterface| Constructor and Description |
|---|
JavaScriptMethodInterceptor(JavaScriptSource<?> jsSource,
VaniContext vaniContext,
List<Object> manualJSInterfaceImplemenations) |
| Modifier and Type | Method and Description |
|---|---|
protected Object[] |
filterArguments(Method jsMethod,
Object[] arguments,
Map<Class<?>,Object> filteredEntries,
Class<?>... filters)
This method will extract all parameters, its class is assignable from
provided filtering classes.
|
protected VaniJavaScriptExecutor |
getExecutor(org.openqa.selenium.JavascriptExecutor jsExecutor) |
protected <T> T |
handleResult(Object result,
Class<T> returnType,
org.openqa.selenium.WebDriver webDriver)
This method checks whether there is a type handler for corresponding
return type and call it when exists.
|
Object |
intercept(Object[] arguments,
Method invokedMethod,
Class<?> targetClass) |
protected Object |
invokeManualImplementation(Method method,
Object... arguments)
This method calls the specified method with given arguments on
corresponding manual implementation instance.
|
protected Object[] |
prepareArgumentsForCustomCallFunc(Object[] arguments,
Map<Class<?>,Object> filteredArguments,
String jsMethodName,
JavaScriptFunction jsFunctionAnnotation)
This method prepares the arguments array for using custom call function.
|
public JavaScriptMethodInterceptor(JavaScriptSource<?> jsSource, VaniContext vaniContext, List<Object> manualJSInterfaceImplemenations)
@RuntimeType public Object intercept(@AllArguments Object[] arguments, @Origin Method invokedMethod, @Origin Class<?> targetClass)
protected <T> T handleResult(Object result, Class<T> returnType, org.openqa.selenium.WebDriver webDriver)
result - returnType - webDriver - result or converted value by registered
TypeHandler.protected VaniJavaScriptExecutor getExecutor(org.openqa.selenium.JavascriptExecutor jsExecutor)
protected Object[] filterArguments(Method jsMethod, Object[] arguments, Map<Class<?>,Object> filteredEntries, Class<?>... filters)
filteredEntries map. The key of the
map will be the filtered class and not the class of parameter
value.
If a parameter entry is NULL, it will extracts the desired type
from corresponding js-method.
jsMethod - calling js-methodarguments - arguments for calling js-methodfilteredEntries - map containing all filtered matchesfilters - array with filter classesNULL if no filters or arguments are available.protected Object[] prepareArgumentsForCustomCallFunc(Object[] arguments, Map<Class<?>,Object> filteredArguments, String jsMethodName, JavaScriptFunction jsFunctionAnnotation)
JavaScriptSource has no call function, provided
arguments array will be returned.
But if there is one, the returned array will only contain the required
parameters for it. So this method is responsible for handling
JsFunctionArguments, JsFunctionName,
GlobalReference.
All others parameters will be ignored
arguments - arguments of calling js functionfilteredArguments - jsMethodName - name of called method of js interfacejsFunctionAnnotation - annotation of called method of js-interfaceprotected Object invokeManualImplementation(Method method, Object... arguments) throws JavaScriptException
method - arguments - NULL if method has void as return type.JavaScriptExceptionCopyright © 2016. All rights reserved.