Skip to main content

RunNativeAPICall

Description​

Gives the ability to create and run scripts that are based on the Native API methods available for the class of the element.

info

Note: This command will work only on instrumented applications.

Parameters​

NameValueDescription
ZoneString with valid values as



* NATIVE

* WEB

* TEXT
Select Zone
ElementIntegerSelect Element (should use xPath)
IndexIntegerElement index
ScriptStringThe Native API script that will run on the identified element

Usage​

Command be used to run scripts based on Native API call. See the example below.

info

Replace <server> with the appropriate URL.

Example

Consider a video element identified by id named 'video_view'.

If there is script to, 

  • view.pause - will pause the video.
  • view.getDuration - will return the total length of the video in milliseconds.
  • view.seekTo - will move the video to a specific time position.

then this command can be used to execute the script such that all actions above can be performed.

DesiredCapabilities dc = new DesiredCapabilities();
driver = new AndroidDriver(new URL("<server>"), dc);
seetest = new SeeTestClient(driver);
dc.setCapability(MobileCapabilityType.UDID, "<deviceid>");

...
...
// Run the script on the element identified by "xpath=//*[@id='video_view']"
seetest.runNativeAPICall("NATIVE", "xpath=//*[@id='video_view']", 0, "view.pause(); var length = view.getDuration(); length = length*0.9; view.seekTo(length);");