Skip to content

browserstack/mstest-appium-app-browserstack

Repository files navigation

MSTest-appium-app-browserstack

This sample elaborates the MSTest Integration with BrowserStack.

To perform tests using SDK, please checkout the sdk branch

Setup

Installation Steps

  1. Clone the repository.
  2. Open the solution mstest-appium-app-browserstack.sln in Visual Studio.
  3. Install dependencies using NuGet Package Manager:
    dotnet restore
  4. Build the solution

Adding Credentials

  1. Add your BrowserStack Username and Access Key to the Config/*.json files in the project.

    {
        "userName": "BROWSERSTACK_USERNAME",
        "accessKey": "BROWSERSTACK_ACCESS_KEY",
    }
  2. Alternatively, you can set environment variables given below. Note that the creds supplied in the config json files above, takes precedence over environment variables. In order to use env variables, remove the userName and accessKey from the config json files altogether.

    • BROWSERSTACK_USERNAME
    • BROWSERSTACK_ACCESS_KEY

You can get your browserstack credentials from here

Uploading App

  • Upload the app using the Browserstack REST API.

  • The response contains the app hashed id:

    {
        "app_url": "bs://<app_hashed_id>"
    }
  • Paste this app hashed id to the corresponding config file. For Example: The sample android app used for Android Single Test can be found here. Upload the app and paste the hashed id here.

Running Tests

  • To run tests, execute the following command:

    dotnet test
  • To run tests on Android/iOS, provide <os> to the below command. Where os can take either of two values: Android or iOS.

    dotnet test <os>
  • To run the single test, execute the following command:

    dotnet test <os> --filter SingleTest
  • To run tests in parallel, execute the following command:

    dotnet test <os> --filter ParallelTest
  • To run local tests, execute the following command:

    dotnet test <os> --filter LocalTest

Understand how many parallel sessions you need by using our Parallel Test Calculator

Notes

  • You can view your test results on the BrowserStack automate dashboard

  • To test on a different set of devices or build a set of appium capabilities, use our Capability Builder

  • You can export the environment variables for the Username and Access Key of your BrowserStack account

    • For Unix-like or Mac machines:
    export BROWSERSTACK_USERNAME=<browserstack-username> &&
    export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
    
    • For Windows Cmd:
    set BROWSERSTACK_USERNAME=<browserstack-username>
    set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
    
    • For Windows Powershell:
    $env:BROWSERSTACK_USERNAME=<browserstack-username>
    $env:BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
    

Additional Resources

About

Sample Repo for running Appium Sessions using MSTest Framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages