From this article you will learn how to pass additional parameters to Selenium or Appium target, even if they can not be specified in a profile.  This recipe can be also used to override parameters of a profile right from a test code.

Requires Rapise 5.3+

Selenium

To pass additional capabilities to Selenium implement the following function in *.user.js file of a test.

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

// set capabilities based on profile name
    if (profile == "Android")
    {
        caps["platformName"] = "Android";
        caps["platformVersion"] = "5.1";
        caps["deviceName"] = "Android Emulator";
        caps["browserName"] = "Browser";
    }
    else if (profile == "iPhone")
    {
        caps["platformName"] = "iOS";
        caps["platformVersion"] = "10.3";
        caps["deviceName"] = "iPhone 5s";
        caps["browserName"] = "Safari";
        caps["automationName"] = "XCUITest";
        caps["newCommandTimeout"] = "300";
    }
    else if (profile == "iPad")
    {
        caps["platformName"] = "iOS";
        caps["platformVersion"] = "10.3";
        caps["deviceName"] = "iPad Air 2";
        caps["browserName"] = "Safari";
        caps["automationName"] = "XCUITest";
        caps["newCommandTimeout"] = "300";
    }    
    return caps;
}

This function is automatically executed by Rapise before creating a WebDriver instance.   Capabilities specified in the callback are applied after capabilities from a profile.

Appium

To pass additional capabilities to Appium implement the following function in *.user.js file of a test.

function GetAppiumNonProfileCapabilities(profile)
{
    var caps = {};
    
// set capabilities based on a profile name
    if (profile == "SL iOS Browser")
    {
        caps["name"] = "ios_check";
    }
    
    return caps;
}

This function is automatically executed by Rapise before creating an AppiumDriver instance.   Capabilities specified in the callback are applied after capabilities from a profile.

Article Info
  • Last Updated: 8/22/2017
  • Article ID: KB280
  • Views: 291