Skip to content

Commit 7e13f3a

Browse files
authored
Merge pull request #17 from browserstack/merge_sdk_to_master
Merge sdk to master
2 parents 9922adc + 1a42c67 commit 7e13f3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+362
-1916
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.vs
2+
bin/
3+
obj
4+
*.err
5+
.DS_Store
6+
log/

README.md

+27-14
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,41 @@ Getting Started with Appium tests in NUnit on BrowserStack devices couldn't be e
1818

1919
### **Run first test :**
2020

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

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

25-
- 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)
25+
- 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.
2626

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

29-
- Switch to `appium_dotnet_driver_4_examples`(or `appium_dotnet_driver_3_examples`) under `android` or `ios` directory
29+
- 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)
3030

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

33-
- 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)
33+
- Open the project in Visual Studio by opening `nunit-appium-app-browserStack.sln` file
3434

35-
### **Use Local testing for apps that access resources hosted in development or testing environments :**
35+
- Go to `android` or `ios` directory
36+
37+
- Ensure that `browserstackLocal` capability is set to `true` in the `browserstack.yml` file
3638

37-
- Switch to `appium_dotnet_driver_4_examples`(or `appium_dotnet_driver_3_examples`) under `android` or `ios` directory
39+
- 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.
3840

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

41-
- 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)
43+
- 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)
4244

43-
**Note**: If you are running Local test on Mac, you need to download and run the BrowserStack Local binary before starting the test:
45+
### **Integrate your test suite**
46+
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:
4447

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

4857
## Integration with other CSharp frameworks
4958

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

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

65+
--
66+
5667
## Troubleshooting
5768

5869
- 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 :
@@ -63,6 +74,8 @@ Note: For other test frameworks supported by App-Automate refer our [Developer d
6374

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

77+
--
78+
6679
## Getting Help
6780

6881
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).

android/BrowserStackNUnitTest.cs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using NUnit.Framework;
2+
using OpenQA.Selenium.Remote;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Collections.Specialized;
6+
using System.Configuration;
7+
using OpenQA.Selenium.Appium.Android;
8+
using OpenQA.Selenium.Chrome;
9+
using OpenQA.Selenium.Appium;
10+
using OpenQA.Selenium.Appium.Enums;
11+
using OpenQA.Selenium.Appium.iOS;
12+
13+
namespace BrowserStack
14+
{
15+
public class BrowserStackNUnitTest
16+
{
17+
protected AndroidDriver<AndroidElement> driver;
18+
public BrowserStackNUnitTest() {}
19+
20+
[SetUp]
21+
public void Init()
22+
{
23+
AppiumOptions appiumOptions = new AppiumOptions();
24+
appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "Samsung Galaxy S20");
25+
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "Android");
26+
appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "10");
27+
driver = new AndroidDriver<AndroidElement>(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions);
28+
}
29+
30+
[TearDown]
31+
public void Cleanup()
32+
{
33+
driver.Quit();
34+
}
35+
36+
}
37+
}

android/LocalSample.apk

3.84 MB
Binary file not shown.

android/appium_dotnet_driver_3_examples/local-test/LocalTest.cs android/SampleLocalTest.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
using System;
1+
using System;
22
using System.Threading;
33
using System.Collections.ObjectModel;
44
using NUnit.Framework;
55
using OpenQA.Selenium;
66
using OpenQA.Selenium.Appium.Android;
77
using OpenQA.Selenium.Support.UI;
88

9-
namespace android.local
9+
namespace BrowserStack
1010
{
11-
[TestFixture("local", "pixel-3")]
11+
[TestFixture]
12+
[Category("sample-local-test")]
1213
public class LocalTest : BrowserStackNUnitTest
1314
{
14-
public LocalTest(string profile, string device) : base(profile,device) {}
15+
public LocalTest() : base() {}
1516

1617
[Test]
1718
public void testLocal()

android/appium_dotnet_driver_3_examples/first-test/FirstTest.cs android/SampleTest.cs

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Threading;
33
using System.Collections.ObjectModel;
44
using NUnit.Framework;
@@ -7,12 +7,13 @@
77
using OpenQA.Selenium.Appium.Android;
88
using OpenQA.Selenium.Support.UI;
99

10-
namespace android.first
10+
namespace BrowserStack
1111
{
12-
[TestFixture("first","pixel-3")]
13-
public class SingleTest : BrowserStackNUnitTest
12+
[TestFixture]
13+
[Category("sample-test")]
14+
public class SampleTest : BrowserStackNUnitTest
1415
{
15-
public SingleTest(string profile, string device) : base(profile,device){}
16+
public SampleTest() : base(){}
1617

1718
[Test]
1819
public void searchWikipedia()

android/WikipediaSample.apk

19.4 MB
Binary file not shown.

android/android.csproj

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<RootNamespace>BrowserStack</RootNamespace>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
9+
<IsPackable>false</IsPackable>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
14+
<PackageReference Include="NUnit" Version="3.13.3" />
15+
<PackageReference Include="NUnit.Analyzers" Version="3.3.0" />
16+
<PackageReference Include="NUnit3TestAdapter" Version="4.3.1" />
17+
<PackageReference Include="Appium.WebDriver" Version="4.4.0" />
18+
<PackageReference Include="BrowserStack.TestAdapter" Version="0.*" />
19+
</ItemGroup>
20+
21+
</Project>

android/appium_dotnet_driver_3_examples/App.config

-56
This file was deleted.

android/appium_dotnet_driver_3_examples/android.csproj

-73
This file was deleted.

android/appium_dotnet_driver_3_examples/android.sln

-17
This file was deleted.

0 commit comments

Comments
 (0)