Execute Tests in BrowserStack

Learn to use BELLATRIX to execute iOS tests in BrowserStack.

Example

[TestClass]
[IOSBrowserStack("pngG38y26LZ5muB1p46P",
    "11.3",
    "iPhone 6",
    AppBehavior.RestartEveryTime,
    captureVideo: true,
    captureNetworkLogs: true,
    consoleLogType: BrowserStackConsoleLogType.Disable,
    debug: false,
    build: "CI Execution")]
public class BrowserStackTests : IOSTest
{
    [TestMethod]
    public void ButtonClicked_When_CallClickMethod()
    {
        var button = App.ElementCreateService.CreateByName<Button>("ComputeSumButton");

        button.Click();
    }

    [TestMethod]
    [IOSBrowserStack("pngG38y26LZ5muB1p46P",
        "11.3",
        "iPhone 6",
        AppBehavior.RestartOnFail,
        captureVideo: true,
        captureNetworkLogs: true,
        consoleLogType: BrowserStackConsoleLogType.Disable,
        debug: false,
        build: "CI Execution")]
    public void ButtonClicked_When_CallClickMethodSecond()
    {
        var button = App.ElementCreateService.CreateByName<Button>("ComputeSumButton");

        button.Click();
    }
}

Explanations

[IOSBrowserStack("pngG38y26LZ5muB1p46P",
    "11.3",
    "iPhone 6",
    AppBehavior.RestartEveryTime,
    captureVideo: true,
    captureNetworkLogs: true,
    consoleLogType: BrowserStackConsoleLogType.Disable,
    debug: false,
    build: "CI Execution")]

To execute BELLATRIX tests in BrowserStack cloud, you should use the BrowserStack attribute instead of IOS. BrowserStack has the same parameters as IOS but adds to additional ones- device name, captureVideo, captureNetworkLogs, consoleLogType, build and debug. The last five are optional and have default values. As with the IOS attribute you can override the class behaviour on Test level.

[TestMethod]
[IOSBrowserStack("pngG38y26LZ5muB1p46P",
    "11.3",
    "iPhone 6",
    AppBehavior.RestartOnFail,
    captureVideo: true,
    captureNetworkLogs: true,
    consoleLogType: BrowserStackConsoleLogType.Disable,
    debug: false,
    build: "CI Execution")]
public void ButtonClicked_When_CallClickMethodSecond()
{
    var button = App.ElementCreateService.CreateByName<Button>("ComputeSumButton");

    button.Click();
}

As mentioned if you use the BrowserStack attribute on method level it overrides the class settings.

Configuration

"browserStack": {
   "gridUri":  "http://hub-cloud.browserstack.com/wd/hub/",
   "user": "soioa1",
   "key":  "pnFG3Ky2yLZ5muB1p46P"
}

You can find a dedicated section about SauceLabs in testFrameworkSettings.json file under the mobileSettings section. There you can set the grid URL and credentials.