.NET client for the BrowserStack Automate REST API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.azure-pipelines
.github
.vscode
src/MartinCostello.BrowserStack.Automate
tests/MartinCostello.BrowserStack.Automate.Tests
.editorconfig
.gitattributes
.gitignore
.travis.yml
Build.ps1
CODE_OF_CONDUCT.md
CommonAssemblyInfo.cs
Directory.Build.props
Directory.Build.targets
LICENSE
MartinCostello.BrowserStack.Automate.ruleset
MartinCostello.BrowserStack.Automate.sln
MartinCostello.BrowserStack.Automate.snk
NuGet.config
README.md
appveyor.yml
browserstack-logo.png
build.sh
global.json
stylecop.json

README.md

Alt text BrowserStack Automate REST API .NET Client

NuGet

Build Status

Linux/OS X Windows Linux/macOS/Windows
Build Status Build status Build status Azure Pipelines build status
Build History Build history Build history Build history

Overview

This repository contains a .NET client library/NuGet package for the BrowserStack Automate REST API.

Features include:

  • Querying the status of a BrowserStack Automate plan.
  • Querying the available browsers.
  • Querying and deleting builds.
  • Querying and deleting projects.
  • Querying and deleting sessions.
  • Querying session log.
  • Setting the status of a session.
  • Regenerating the API access key.

The assembly supports .NET Core (via .NET Standard 1.3 and .NET Standard 2.0) and .NET Framework 4.5.1.

Installation

Install-Package MartinCostello.BrowserStack.Automate

Usage Examples

The following example shows a custom xUnit.net [Trait] that checks for an available BrowserStack Automate session before running the test, otherwise it is skipped.

namespace MyApp.Tests
{
    using System;
    using System.Configuration;
    using MartinCostello.BrowserStack.Automate;
    using Xunit;

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
    public sealed class RequiresBrowserStackAutomateAttribute : FactAttribute
    {
        public RequiresBrowserStackAutomateAttribute()
        {
            string userName = Environment.GetEnvironmentVariable("BrowserStack_UserName");
            string accessKey = Environment.GetEnvironmentVariable("BrowserStack_AccessKey");

            var client = new BrowserStackAutomateClient(userName, accessKey);
            var plan = client.GetStatusAsync().Result;

            if (plan.MaximumAllowedParallelSessions < 1 ||
                plan.ParallelSessionsRunning == plan.MaximumAllowedParallelSessions)
            {
                Skip = "No BrowserStack Automate sessions are currently available.";
            }
        }
    }
}

Feedback

Any feedback or issues can be added to the issues for this project in GitHub.

Repository

The repository is hosted in GitHub: https://github.com/martincostello/browserstack-automate.git

License

This project is licensed under the Apache 2.0 license.

Building and Testing

To build and test the assembly run one of the following set of commands:

Linux/OS X

EXPORT BrowserStack_UserName  = "MyUserName"
EXPORT BrowserStack_AccessKey = "MyAccessKey"
./build.sh

Windows

$env:BrowserStack_UserName  = "MyUserName"
$env:BrowserStack_AccessKey = "MyAccessKey"
.\Build.ps1

If you do not have a BrowserStack Automate access key you can still just run the build script and the integration tests that require credentials will be skipped.