Skip to content

Commit

Permalink
Merge pull request #17 from browserstack/merge_sdk_to_master
Browse files Browse the repository at this point in the history
Merge sdk to master
  • Loading branch information
yashdsaraf authored Jul 3, 2024
2 parents 9922adc + 1a42c67 commit 7e13f3a
Show file tree
Hide file tree
Showing 54 changed files with 362 additions and 1,916 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vs
bin/
obj
*.err
.DS_Store
log/
41 changes: 27 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,41 @@ Getting Started with Appium tests in NUnit on BrowserStack devices couldn't be e

### **Run first test :**

- Switch to `appium_dotnet_driver_4_examples`(or `appium_dotnet_driver_3_examples`) under `android` or `ios` directory
- Open the project in Visual Studio by opening `nunit-appium-app-browserStack.sln` file

- Open the project in Visual Studio by opening `android.sln` or `ios.sln` file
- Go to `android` or `ios` directory

- Follow the steps outlined in the documentation to run your first test - [Get Started with your first test on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/c-sharp/nunit)
- If you have uploaded your app then add the app id to the `browserstack.yml` config file, or you can directly specify the path to your app in the `browserstack.yml` file.

### **Speed up test execution with parallel testing :**
- Run `dotnet test --filter "Category=sample-test"`

- Switch to `appium_dotnet_driver_4_examples`(or `appium_dotnet_driver_3_examples`) under `android` or `ios` directory
- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)

- Open the project in Visual Studio by opening `android.sln` or `ios.sln` file
### **Use Local testing for apps that access resources hosted in development or testing environments :**

- Follow the steps outlined in the documentation to run parallel tests - [Get Started with Parallel testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/c-sharp/nunit/parallelize-tests)
- Open the project in Visual Studio by opening `nunit-appium-app-browserStack.sln` file

### **Use Local testing for apps that access resources hosted in development or testing environments :**
- Go to `android` or `ios` directory

- Ensure that `browserstackLocal` capability is set to `true` in the `browserstack.yml` file

- Switch to `appium_dotnet_driver_4_examples`(or `appium_dotnet_driver_3_examples`) under `android` or `ios` directory
- If you have uploaded your app then add the app id to the `browserstack.yml` config file, or you can directly specify the path to your app in the `browserstack.yml` file.

- Open the project in Visual Studio by opening `android.sln` or `ios.sln` file
- Run `dotnet test --filter "Category=sample-local-test"`

- Follow the steps outlined in the documentation to run local tests - [Get Started with Local testing on App Automate](https://www.browserstack.com/docs/app-automate/appium/getting-started/c-sharp/nunit/local-testing)
- You can access the test execution results, and debugging information such as video recording, network logs on [App Automate dashboard](https://app-automate.browserstack.com/dashboard)

**Note**: If you are running Local test on Mac, you need to download and run the BrowserStack Local binary before starting the test:
### **Integrate your test suite**
This repository uses the BrowserStack SDK to run tests on BrowserStack. Follow the steps below to install the SDK in your test suite and run tests on BrowserStack:

1. Download BrowserStack Local binary for mac: [OS X (10.7 and above)](https://www.browserstack.com/browserstack-local/BrowserStackLocal-darwin-x64.zip)
2. Switch to the directory where binary is downloaded and run using following command `./BrowserStackLocal --key <YOUR_ACCESS_KEY>`
- Create sample browserstack.yml file with the browserstack related capabilities with your BrowserStack Username and Access Key and place it in your root folder.
- Add nuget library BrowserStack.TestAdapter
```sh
dotnet add BrowserStack.TestAdapter
```
- Build project dotnet build

--

## Integration with other CSharp frameworks

Expand All @@ -53,6 +62,8 @@ For other CSharp frameworks samples, refer to following repositories :

Note: For other test frameworks supported by App-Automate refer our [Developer documentation](https://www.browserstack.com/docs/)

--

## Troubleshooting

- In case `Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json'` issue is encountered while running a Local test on Windows, please follow the these steps to resolve it :
Expand All @@ -63,6 +74,8 @@ Note: For other test frameworks supported by App-Automate refer our [Developer d

- Then run `update-package Newtonsoft.Json` in the same console

--

## Getting Help

If you are running into any issues or have any queries, please check [Browserstack Support page](https://www.browserstack.com/support/app-automate) or [get in touch with us](https://www.browserstack.com/contact?ref=help).
37 changes: 37 additions & 0 deletions android/BrowserStackNUnitTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using NUnit.Framework;
using OpenQA.Selenium.Remote;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Enums;
using OpenQA.Selenium.Appium.iOS;

namespace BrowserStack
{
public class BrowserStackNUnitTest
{
protected AndroidDriver<AndroidElement> driver;
public BrowserStackNUnitTest() {}

[SetUp]
public void Init()
{
AppiumOptions appiumOptions = new AppiumOptions();
appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Samsung Galaxy S20");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "10");
driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
}

[TearDown]
public void Cleanup()
{
driver.Quit();
}

}
}
Binary file added android/LocalSample.apk
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
using System;
using System;
using System.Threading;
using System.Collections.ObjectModel;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Support.UI;

namespace android.local
namespace BrowserStack
{
[TestFixture("local", "pixel-3")]
[TestFixture]
[Category("sample-local-test")]
public class LocalTest : BrowserStackNUnitTest
{
public LocalTest(string profile, string device) : base(profile,device) {}
public LocalTest() : base() {}

[Test]
public void testLocal()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading;
using System.Collections.ObjectModel;
using NUnit.Framework;
Expand All @@ -7,12 +7,13 @@
using OpenQA.Selenium.Appium.Android;
using OpenQA.Selenium.Support.UI;

namespace android.first
namespace BrowserStack
{
[TestFixture("first","pixel-3")]
public class SingleTest : BrowserStackNUnitTest
[TestFixture]
[Category("sample-test")]
public class SampleTest : BrowserStackNUnitTest
{
public SingleTest(string profile, string device) : base(profile,device){}
public SampleTest() : base(){}

[Test]
public void searchWikipedia()
Expand Down
Binary file added android/WikipediaSample.apk
Binary file not shown.
21 changes: 21 additions & 0 deletions android/android.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>BrowserStack</RootNamespace>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
<PackageReference Include="Appium.WebDriver" Version="4.4.0" />
<PackageReference Include="BrowserStack.TestAdapter" Version="0.*" />
</ItemGroup>

</Project>
56 changes: 0 additions & 56 deletions android/appium_dotnet_driver_3_examples/App.config

This file was deleted.

73 changes: 0 additions & 73 deletions android/appium_dotnet_driver_3_examples/android.csproj

This file was deleted.

17 changes: 0 additions & 17 deletions android/appium_dotnet_driver_3_examples/android.sln

This file was deleted.

Loading

0 comments on commit 7e13f3a

Please sign in to comment.