Dynamic invoke enables you to directly call methods of the underlying Appium WebDriver for a mobile native app. This is useful whenever an Appium WebDriver method is not exposed through the Silk4J API.
Call multiple dynamic methods on objects with the invokeMethods method. To retrieve a list of supported dynamic methods for a control, use the getDynamicMethodList method.
Both primitive types, such as int, and object types, such as java.lang.Integer are supported. Primitive types are widened if necessary, allowing, for example, to pass an int where a long is expected.
Enum parameters must be passed as string. The string must match the name of an enum value. For example, if the method expects a parameter of the enum ScreenOrientation, you can use the string values LANDSCAPE or PORTRAIT.
Allows calling methods with list, array, or var-arg parameters. Conversion to an array type is done automatically, provided the elements of the list are assignable to the target array type.
The following code sample contains some common examples for using dynamic invoke.
// Java code MobileDevice device = desktop.find("//MobileDevice"); // Getting the page source String pageSource = (String) device.invoke("getPageSource"); // Resetting an app device.invoke("resetApp"); // Changing the device orientation device.invoke("rotate", "LANDSCAPE"); device.invoke("rotate", "PORTRAIT"); // Dynamic invoke on MobileObject (calls get redirected to the underlying web element for WebDriver) device.<MobileObject> find("//MobileObject[@caption='CheckBox 2']").invoke("click");