Skip to content

Latest commit

 

History

History
171 lines (123 loc) · 8.62 KB

File metadata and controls

171 lines (123 loc) · 8.62 KB

Welcome to BrowserStack NUnit Examples, a sample UI testing framework empowered with Appium and NUnit. Along with the framework the repository also contains a collection of sample test scripts written for BrowserStack Demo Application.

This repository includes a number of sample configuration files to run these on tests on BrowserStack platforms including **browsers running on a remote selenium grid such as BrowserStack AppAutomate

Tests Included in this Repository

Following are the test cases included in this repository:

Module Test Case Description
Login PerformLoginValidCreds Test case Perform Login with valid credentials
Login PerformLoginNoCreds Test case Perform Login with Blank credentials
Browse CheckItemCount Test case validates Item counts on initial state of App
Browse AddNewItem Test case adds new item validates newly added item
About GoToAboutTab Test case navigates to About tab

Prerequisites

Ensure you have the following dependencies installed on the machine

  1. Dotnet (3 or above)
  2. Allure Command Line Tool
  3. BrowserStack AppAutomate Account. BrowserStack
  4. Upload Your App on BrowserStack
    Click here for more details on how to upload an app.

For this example repository, the sample apps are available here:

  1. Xamarin: bin/xamarin/SimpleApp_Android.apk, bin/xamarin/SimpleApp_iOS.ipa

Setup with Nunit

📌 Clone this repository


📌 Navigate to the repository directory
       cd browserstack-examples-appium-nunit

📌 Restore the required nuget pakages
       dotnet restore

📌 Build the project
       dotnet build

The repository is designed to execute test on list of Device's hosted on BrowserStack
List of devices could be found here

On BrowserStack AppAutomate, you can spin multiple Devices instances in parallel to reduce your over all build time. With NUnit you configure the number concurrent test executions to an optimal count by configuring through AssemblyInfo.cs

Test Execution Prerequisites BrowserStack

📌 Create a new BrowserStack account or use an existing one.

📌 Identify your BrowserStack username and access key from the BrowserStack App-Automate Dashboard and export them as environment variables using the below commands.
      

  • For Unix-like or Mac machines:
export BROWSERSTACK_USERNAME=<browserstack-username> &&
export BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
export CAPABILITIES_FILENAME=<capabilities_file>
export BROWSERSTACK_ANDROID_APP_ID=<APP_BSTACK_URL__OR__CUSTOM_ID>
export BROWSERSTACK_IOS_APP_ID=<APP_BSTACK_URL__OR__CUSTOM_ID>
  • For Windows:
set BROWSERSTACK_USERNAME=<browserstack-username>
set BROWSERSTACK_ACCESS_KEY=<browserstack-access-key>
set CAPABILITIES_FILENAME=<capabilities_file>
set BROWSERSTACK_ANDROID_APP_ID=<APP_BSTACK_URL__OR__CUSTOM_ID>
set BROWSERSTACK_IOS_APP_ID=<APP_BSTACK_URL__OR__CUSTOM_ID>

📄 Note: We have configured a list of test capabilities in these configuration files

Default Configuration file: CAPABILITIES_FILENAME = capabilities.yml. This default capabilities file and other test configuration files reside in the below folder: browserstack-examples-appium-nunit/Browserstack/Webdriver/Resources/

Feel free to update the configurations based on your device and test requirements. The exact test capability values can be easily identified using the Browserstack Capability Generator

Test Execution Profiles

Following are the preconfigured test execution profiles.

Profile Description Dotnet Command Example command
Single Test Execution
Runs a single test on a two devices Android & iOS parallely on BrowserStack. dotnet test --filter "Method Name" dotnet test --filter "CheckItemCount"
Parallel Execution
Concurrently runs the entire test suite on a multiple Devices on BrowserStack. dotnet test dotnet test
Parallel Execution with additonal flags
Concurrently runs the entire test suite on a multiple Devices on BrowserStack based on capabilities file, logger and a dotnet test runsettings specified at runtime CAPABILITIES_FILENAME=<capability_file_name.yml> dotnet test --logger:"<NUnit_Logger>" -s <runsettings_file_with_additional_flags> CAPABILITIES_FILENAME=capabilities.yml dotnet test --logger:"nunit;LogFilePath=test-results/results.xml" -s test.runsettings