Appium is still needed at the backend to drive the mobile target. But we can connect to it using  the Web library in Rapise.

For this purpose we'll define GetWebDriverNonProfileCapabilities callback like this:

function GetWebDriverNonProfileCapabilities(profile)
{
	var caps = {};

	// This is to prevent empty URL navigatoin in a mobile app
	WebDriver.reconnected = true;

	if (profile == "Chrome")
	{
		caps["appium:platformName"] = "Android";
		caps["appium:androidPackage"] = "io.ionic.demo.pg.cap.ng";
		caps["appium:newCommandTimeout"] = 600;
		caps["appium:app"] = "/path/to/ionic-demo-app.apk";
	}
	return caps;
}

Using the Web library and the Web Spy we can learn objects.

Also if we need to do a hybrid testing and deal with some controls via Mobile library we may use another handy function:

function SaveMobileSession()
{
	var sessionId = Global.GetProperty("SeleniumSessionId", "", WebDriver.webDriverSessionFileName);
	var addressOfRemoteServer = Global.GetProperty("SeleniumAddressOfRemoteServer", "", WebDriver.webDriverSessionFileName);
	var profileName = g_mobileProfile;

 	Tester.Message(sessionId);
	Tester.Message(addressOfRemoteServer);

	Global.SetProperty("AppiumProfile", profileName, AppiumDriver.appiumDriverSessionFileName);
	Global.SetProperty("AppiumSessionId", sessionId, AppiumDriver.appiumDriverSessionFileName);
	Global.SetProperty("AppiumAddressOfRemoteServer", addressOfRemoteServer, AppiumDriver.appiumDriverSessionFileName);
}

Call it after creating/reconnecting a Web session. It will save data for Mobile connection and it will be possible to connect with Mobile library as well as Mobile Spy.

To switch from Web mode to Mobile mode and back use BeforeMobile and AfterMobile functions.

var webContext;
function BeforeMobile()
{
	AppiumDriver.ReconnectSession(false);
	webContext = AppiumDriver.GetContext();
	AppiumDriver.SetContext("NATIVE_APP");
}

function AfterMobile()
{
	AppiumDriver.SetContext(webContext);
}