diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..50d8a3b --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +.vs +bin/ +obj +*.err +.DS_Store +log/ diff --git a/README.md b/README.md index 75b88c3..34ba710 100644 --- a/README.md +++ b/README.md @@ -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 ` +- 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 @@ -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 : @@ -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). diff --git a/android/BrowserStackNUnitTest.cs b/android/BrowserStackNUnitTest.cs new file mode 100644 index 0000000..e4a74d7 --- /dev/null +++ b/android/BrowserStackNUnitTest.cs @@ -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 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(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions); + } + + [TearDown] + public void Cleanup() + { + driver.Quit(); + } + + } +} diff --git a/android/LocalSample.apk b/android/LocalSample.apk new file mode 100644 index 0000000..f31c574 Binary files /dev/null and b/android/LocalSample.apk differ diff --git a/android/appium_dotnet_driver_3_examples/local-test/LocalTest.cs b/android/SampleLocalTest.cs similarity index 88% rename from android/appium_dotnet_driver_3_examples/local-test/LocalTest.cs rename to android/SampleLocalTest.cs index dd9fc32..e28a4fa 100644 --- a/android/appium_dotnet_driver_3_examples/local-test/LocalTest.cs +++ b/android/SampleLocalTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Collections.ObjectModel; using NUnit.Framework; @@ -6,12 +6,13 @@ 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() diff --git a/android/appium_dotnet_driver_3_examples/first-test/FirstTest.cs b/android/SampleTest.cs similarity index 82% rename from android/appium_dotnet_driver_3_examples/first-test/FirstTest.cs rename to android/SampleTest.cs index 8b1432d..3c73daf 100644 --- a/android/appium_dotnet_driver_3_examples/first-test/FirstTest.cs +++ b/android/SampleTest.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Collections.ObjectModel; using NUnit.Framework; @@ -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() diff --git a/android/WikipediaSample.apk b/android/WikipediaSample.apk new file mode 100644 index 0000000..03d19e6 Binary files /dev/null and b/android/WikipediaSample.apk differ diff --git a/android/android.csproj b/android/android.csproj new file mode 100644 index 0000000..4aac919 --- /dev/null +++ b/android/android.csproj @@ -0,0 +1,21 @@ + + + + net6.0 + BrowserStack + enable + enable + + false + + + + + + + + + + + + diff --git a/android/appium_dotnet_driver_3_examples/App.config b/android/appium_dotnet_driver_3_examples/App.config deleted file mode 100644 index 6e0a79d..0000000 --- a/android/appium_dotnet_driver_3_examples/App.config +++ /dev/null @@ -1,56 +0,0 @@ - - - - -
-
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/appium_dotnet_driver_3_examples/android.csproj b/android/appium_dotnet_driver_3_examples/android.csproj deleted file mode 100644 index ad9ab56..0000000 --- a/android/appium_dotnet_driver_3_examples/android.csproj +++ /dev/null @@ -1,73 +0,0 @@ - - - - Debug - AnyCPU - {41750684-85C3-4F6C-9B7A-F8141025E30A} - Library - android - android - v4.6.1 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - - - true - bin\Release - prompt - 4 - - - - - - - packages\Castle.Core.4.3.1\lib\net45\Castle.Core.dll - - - packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll - - - packages\Selenium.WebDriver.3.6.0\lib\net45\WebDriver.dll - - - packages\Selenium.Support.3.6.0\lib\net45\WebDriver.Support.dll - - - packages\NUnit.3.8.0\lib\net45\nunit.framework.dll - - - packages\BrowserStackLocal.1.4.0\lib\net20\BrowserStackLocal.dll - - - packages\Appium.WebDriver.3.0.0.2\lib\net45\appium-dotnet-driver.dll - - - packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - - - - - - - - - - - - - - - - - - - - diff --git a/android/appium_dotnet_driver_3_examples/android.sln b/android/appium_dotnet_driver_3_examples/android.sln deleted file mode 100644 index fb0d947..0000000 --- a/android/appium_dotnet_driver_3_examples/android.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "android", "android.csproj", "{41750684-85C3-4F6C-9B7A-F8141025E30A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/android/appium_dotnet_driver_3_examples/first-test/BrowserStackNUnitTest.cs b/android/appium_dotnet_driver_3_examples/first-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 839baff..0000000 --- a/android/appium_dotnet_driver_3_examples/first-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,72 +0,0 @@ -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; - -namespace android.first -{ - public class BrowserStackNUnitTest - { - protected AndroidDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - DesiredCapabilities capability = new DesiredCapabilities(); - - foreach (string key in caps.AllKeys) - { - capability.SetCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - capability.SetCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - capability.SetCapability("browserstack.user", username); - capability.SetCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - capability.SetCapability("app", appId); - } - - driver = new AndroidDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - - } -} diff --git a/android/appium_dotnet_driver_3_examples/local-test/BrowserStackNUnitTest.cs b/android/appium_dotnet_driver_3_examples/local-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 0bbc613..0000000 --- a/android/appium_dotnet_driver_3_examples/local-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,92 +0,0 @@ -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 BrowserStack; -using System.Runtime.InteropServices; - -namespace android.local -{ - public class BrowserStackNUnitTest - { - protected AndroidDriver driver; - protected string profile; - protected string device; - private Local browserStackLocal; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - DesiredCapabilities capability = new DesiredCapabilities(); - - foreach (string key in caps.AllKeys) - { - capability.SetCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - capability.SetCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - capability.SetCapability("browserstack.user", username); - capability.SetCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - capability.SetCapability("app", appId); - } - - // if the platform is Windows, enable local testing fropm within the test - // for Mac and GNU/Linux, run the local binary manually to enable local testing (see the docs) - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - && capability.GetCapability("browserstack.local") != null - && capability.GetCapability("browserstack.local").ToString() == "true") - { - browserStackLocal = new Local(); - List> bsLocalArgs = new List>() { - new KeyValuePair("key", accesskey) - }; - browserStackLocal.start(bsLocalArgs); - } - - driver = new AndroidDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - if (browserStackLocal != null) - { - browserStackLocal.stop(); - } - } - - } -} diff --git a/android/appium_dotnet_driver_3_examples/packages.config b/android/appium_dotnet_driver_3_examples/packages.config deleted file mode 100644 index 7064519..0000000 --- a/android/appium_dotnet_driver_3_examples/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/android/appium_dotnet_driver_3_examples/parallel-test/BrowserStackNUnitTest.cs b/android/appium_dotnet_driver_3_examples/parallel-test/BrowserStackNUnitTest.cs deleted file mode 100644 index a4a6a31..0000000 --- a/android/appium_dotnet_driver_3_examples/parallel-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -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; - -namespace android.parallel -{ - public class BrowserStackNUnitTest - { - protected AndroidDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - Console.WriteLine(device); - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - DesiredCapabilities capability = new DesiredCapabilities(); - - foreach (string key in caps.AllKeys) - { - capability.SetCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - capability.SetCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - capability.SetCapability("browserstack.user", username); - capability.SetCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - capability.SetCapability("app", appId); - } - - driver = new AndroidDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - - } -} diff --git a/android/appium_dotnet_driver_3_examples/parallel-test/ParallelTest.cs b/android/appium_dotnet_driver_3_examples/parallel-test/ParallelTest.cs deleted file mode 100644 index 150ecf3..0000000 --- a/android/appium_dotnet_driver_3_examples/parallel-test/ParallelTest.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Threading; -using System.Collections.ObjectModel; -using NUnit.Framework; -using OpenQA.Selenium; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.Android; -using OpenQA.Selenium.Support.UI; - -namespace android.parallel -{ - [TestFixture("parallel", "pixel-3")] - [TestFixture("parallel", "galaxy-s10e")] - [Parallelizable(ParallelScope.Fixtures)] - public class ParallelTest : BrowserStackNUnitTest - { - public ParallelTest(string profile, string device) : base(profile,device){ } - - [Test] - public void searchWikipedia() - { - AndroidElement searchElement = (AndroidElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia"))); - searchElement.Click(); - AndroidElement insertTextElement = (AndroidElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(By.Id("org.wikipedia.alpha:id/search_src_text"))); - insertTextElement.SendKeys("Browserstack"); - Thread.Sleep(5000); - - ReadOnlyCollection allProductsName = driver.FindElements(By.ClassName("android.widget.TextView")); - Assert.True(allProductsName.Count > 0); - } - } -} diff --git a/android/appium_dotnet_driver_4_examples/App.config b/android/appium_dotnet_driver_4_examples/App.config deleted file mode 100644 index 6e0a79d..0000000 --- a/android/appium_dotnet_driver_4_examples/App.config +++ /dev/null @@ -1,56 +0,0 @@ - - - - -
-
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/appium_dotnet_driver_4_examples/android.csproj b/android/appium_dotnet_driver_4_examples/android.csproj deleted file mode 100644 index fa0d0b8..0000000 --- a/android/appium_dotnet_driver_4_examples/android.csproj +++ /dev/null @@ -1,81 +0,0 @@ - - - - - Debug - AnyCPU - {41750684-85C3-4F6C-9B7A-F8141025E30A} - Library - android - android - v4.6.1 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - - - true - bin\Release - prompt - 4 - - - - - - - packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - - packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - packages\Selenium.WebDriver.3.141.0\lib\net45\WebDriver.dll - - - packages\Selenium.Support.3.141.0\lib\net45\WebDriver.Support.dll - - - packages\NUnit.3.12.0\lib\net45\nunit.framework.dll - - - packages\BrowserStackLocal.1.4.0\lib\net20\BrowserStackLocal.dll - - - packages\DotNetSeleniumExtras.PageObjects.3.11.0\lib\net45\SeleniumExtras.PageObjects.dll - - - packages\Appium.WebDriver.4.2.1\lib\net45\Appium.Net.dll - - - packages\DotNetSeleniumExtras.WaitHelpers.3.11.0\lib\net45\SeleniumExtras.WaitHelpers.dll - - - - packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - - - - - - - - - - - - - - - - - - - - diff --git a/android/appium_dotnet_driver_4_examples/android.sln b/android/appium_dotnet_driver_4_examples/android.sln deleted file mode 100644 index fb0d947..0000000 --- a/android/appium_dotnet_driver_4_examples/android.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "android", "android.csproj", "{41750684-85C3-4F6C-9B7A-F8141025E30A}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {41750684-85C3-4F6C-9B7A-F8141025E30A}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/android/appium_dotnet_driver_4_examples/first-test/BrowserStackNUnitTest.cs b/android/appium_dotnet_driver_4_examples/first-test/BrowserStackNUnitTest.cs deleted file mode 100644 index f3c714a..0000000 --- a/android/appium_dotnet_driver_4_examples/first-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,72 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.Android; -using OpenQA.Selenium.Appium; - -namespace android.first -{ - public class BrowserStackNUnitTest - { - protected AndroidDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - AppiumOptions options = new AppiumOptions(); - - foreach (string key in caps.AllKeys) - { - options.AddAdditionalCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - options.AddAdditionalCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - options.AddAdditionalCapability("browserstack.user", username); - options.AddAdditionalCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - options.AddAdditionalCapability("app", appId); - } - - Uri uri = new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"); - driver = new AndroidDriver(uri, options); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - - } -} diff --git a/android/appium_dotnet_driver_4_examples/first-test/FirstTest.cs b/android/appium_dotnet_driver_4_examples/first-test/FirstTest.cs deleted file mode 100644 index f34bc61..0000000 --- a/android/appium_dotnet_driver_4_examples/first-test/FirstTest.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using System.Threading; -using System.Collections.ObjectModel; -using NUnit.Framework; -using OpenQA.Selenium; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.Android; -using OpenQA.Selenium.Support.UI; - -namespace android.first -{ - [TestFixture("first","pixel-3")] - public class SingleTest : BrowserStackNUnitTest - { - public SingleTest(string profile, string device) : base(profile,device){} - - [Test] - public void searchWikipedia() - { - WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); - AndroidElement searchElement = (AndroidElement)wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia"))); - searchElement.Click(); - - AndroidElement insertTextElement = (AndroidElement)wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("org.wikipedia.alpha:id/search_src_text"))); - insertTextElement.SendKeys("BrowserStack"); - Thread.Sleep(5000); - - ReadOnlyCollection allProductsName = driver.FindElements(By.ClassName("android.widget.TextView")); - Assert.True(allProductsName.Count > 0); - } - } -} diff --git a/android/appium_dotnet_driver_4_examples/local-test/BrowserStackNUnitTest.cs b/android/appium_dotnet_driver_4_examples/local-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 8d338b4..0000000 --- a/android/appium_dotnet_driver_4_examples/local-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,93 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.Android; -using OpenQA.Selenium.Appium; -using BrowserStack; -using System.Runtime.InteropServices; - -namespace android.local -{ - public class BrowserStackNUnitTest - { - protected AndroidDriver driver; - protected string profile; - protected string device; - private Local browserStackLocal; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - AppiumOptions options = new AppiumOptions(); - - foreach (string key in caps.AllKeys) - { - options.AddAdditionalCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - options.AddAdditionalCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - options.AddAdditionalCapability("browserstack.user", username); - options.AddAdditionalCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - options.AddAdditionalCapability("app", appId); - } - - // if the platform is Windows, enable local testing fropm within the test - // for Mac and GNU/Linux, run the local binary manually to enable local testing (see the docs) - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - && options.ToCapabilities().HasCapability("browserstack.local") - && options.ToCapabilities().GetCapability("browserstack.local").ToString() == "true") - { - browserStackLocal = new Local(); - List> bsLocalArgs = new List>() { - new KeyValuePair("key", accesskey) - }; - browserStackLocal.start(bsLocalArgs); - } - - Uri uri = new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"); - driver = new AndroidDriver(uri, options); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - if (browserStackLocal != null) - { - browserStackLocal.stop(); - } - } - - } -} diff --git a/android/appium_dotnet_driver_4_examples/local-test/LocalTest.cs b/android/appium_dotnet_driver_4_examples/local-test/LocalTest.cs deleted file mode 100644 index 1784b91..0000000 --- a/android/appium_dotnet_driver_4_examples/local-test/LocalTest.cs +++ /dev/null @@ -1,37 +0,0 @@ -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 -{ - [TestFixture("local", "pixel-3")] - public class LocalTest : BrowserStackNUnitTest - { - public LocalTest(string profile, string device) : base(profile,device){ } - - [Test] - public void testLocal() - { - WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); - AndroidElement searchElement = (AndroidElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("com.example.android.basicnetworking:id/test_action"))); - searchElement.Click(); - AndroidElement testElement = (AndroidElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.ClassName("android.widget.TextView"))); - - ReadOnlyCollection allTextViewElements = driver.FindElements(By.ClassName("android.widget.TextView")); - - Thread.Sleep(5000); - - foreach (AndroidElement textElement in allTextViewElements) - { - if (textElement.Text.Contains("The active connection is")) - { - Assert.True(textElement.Text.Contains("The active connection is wifi"),"Incorrect Text"); - } - } - } - } -} diff --git a/android/appium_dotnet_driver_4_examples/packages.config b/android/appium_dotnet_driver_4_examples/packages.config deleted file mode 100644 index 81b218c..0000000 --- a/android/appium_dotnet_driver_4_examples/packages.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/android/appium_dotnet_driver_4_examples/parallel-test/BrowserStackNUnitTest.cs b/android/appium_dotnet_driver_4_examples/parallel-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 5eb4301..0000000 --- a/android/appium_dotnet_driver_4_examples/parallel-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,71 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.Android; -using OpenQA.Selenium.Appium; - -namespace android.parallel -{ - public class BrowserStackNUnitTest - { - protected AndroidDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - AppiumOptions options = new AppiumOptions(); - - foreach (string key in caps.AllKeys) - { - options.AddAdditionalCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - options.AddAdditionalCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - options.AddAdditionalCapability("browserstack.user", username); - options.AddAdditionalCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - options.AddAdditionalCapability("app", appId); - } - Uri uri = new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"); - driver = new AndroidDriver(uri, options); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - } -} diff --git a/android/appium_dotnet_driver_4_examples/parallel-test/ParallelTest.cs b/android/appium_dotnet_driver_4_examples/parallel-test/ParallelTest.cs deleted file mode 100644 index bca34ea..0000000 --- a/android/appium_dotnet_driver_4_examples/parallel-test/ParallelTest.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System; -using System.Threading; -using System.Collections.ObjectModel; -using NUnit.Framework; -using OpenQA.Selenium; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.Android; -using OpenQA.Selenium.Support.UI; - -namespace android.parallel -{ - [TestFixture("parallel", "pixel-3")] - [TestFixture("parallel", "galaxy-s10e")] - [Parallelizable(ParallelScope.Fixtures)] - public class ParallelTest : BrowserStackNUnitTest - { - public ParallelTest(string profile, string device) : base(profile,device){ } - - [Test] - public void searchWikipedia() - { - WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); - AndroidElement searchElement = (AndroidElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Search Wikipedia"))); - searchElement.Click(); - - AndroidElement insertTextElement = (AndroidElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(By.Id("org.wikipedia.alpha:id/search_src_text"))); - insertTextElement.SendKeys("Browserstack"); - Thread.Sleep(5000); - - ReadOnlyCollection allProductsName = driver.FindElements(By.ClassName("android.widget.TextView")); - Assert.True(allProductsName.Count > 0); - } - } -} diff --git a/android/browserstack.yml b/android/browserstack.yml new file mode 100644 index 0000000..61e6fc7 --- /dev/null +++ b/android/browserstack.yml @@ -0,0 +1,67 @@ +# ============================= +# Set BrowserStack Credentials +# ============================= +# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and +# BROWSERSTACK_ACCESS_KEY as env variables +userName: BROWSERSTACK_USERNAME +accessKey: BROWSERSTACK_ACCESS_KEY + +# ====================== +# BrowserStack Reporting +# ====================== +# The following capabilities are used to set up reporting on BrowserStack: +# Set 'projectName' to the name of your project. Example, Marketing Website +projectName: BrowserStack Samples +# Set `buildName` as the name of the job / testsuite being run +buildName: browserstack build +# `buildIdentifier` is a unique id to differentiate every execution that gets appended to +# buildName. Choose your buildIdentifier format from the available expressions: +# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution +# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30 +# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests +buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression} + +source: 'nunit:appium-sample-sdk:v1.0' + +# Set `app` to define the app that is to be used for testing. +# It can either take the id of any uploaded app or the path of the app directly. +app: ./WikipediaSample.apk +# app: ./LocalSample.apk #For running local tests + +# ======================================= +# Platforms (Browsers / Devices to test) +# ======================================= +# Platforms object contains all the browser / device combinations you want to test on. +# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate) + +platforms: + - deviceName: Samsung Galaxy S22 Ultra + osVersion: 12.0 + platformName: android + - deviceName: Samsung Galaxy S21 + osVersion: 11.0 + platformName: android + - deviceName: Google Pixel 6 Pro + osVersion: 12.0 + platformName: android + +# ========================================== +# BrowserStack Local +# (For localhost, staging/private websites) +# ========================================== +# Set browserStackLocal to true if your website under test is not accessible publicly over the internet +# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction +browserstackLocal: true # (Default false) +#browserStackLocalOptions: +#Options to be passed to BrowserStack local in-case of advanced configurations +# localIdentifier: # (Default: null) Needed if you need to run multiple instances of local. +# forceLocal: true # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel. +# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections + +# =================== +# Debugging features +# =================== +debug: false # # Set to true if you need screenshots for every selenium command ran +networkLogs: false # Set to true to enable HAR logs capturing +consoleLogs: errors # Remote browser's console debug levels to be printed (Default: errors) +# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors) diff --git a/ios/BStackSampleApp.ipa b/ios/BStackSampleApp.ipa new file mode 100644 index 0000000..c1891b8 Binary files /dev/null and b/ios/BStackSampleApp.ipa differ diff --git a/ios/BrowserStackNUnitTest.cs b/ios/BrowserStackNUnitTest.cs new file mode 100644 index 0000000..1ea4c3d --- /dev/null +++ b/ios/BrowserStackNUnitTest.cs @@ -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 IOSDriver driver; + public BrowserStackNUnitTest() {} + + [SetUp] + public void Init() + { + AppiumOptions appiumOptions = new AppiumOptions(); + appiumOptions.AddAdditionalCapability(MobileCapabilityType.DeviceName, "iPhone 14 Pro"); + appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformName, "ios"); + appiumOptions.AddAdditionalCapability(MobileCapabilityType.PlatformVersion, "16"); + driver = new IOSDriver(new Uri("http://127.0.0.1:4723/wd/hub"), appiumOptions); + } + + [TearDown] + public void Cleanup() + { + driver.Quit(); + } + + } +} diff --git a/ios/LocalSample.ipa b/ios/LocalSample.ipa new file mode 100644 index 0000000..a937349 Binary files /dev/null and b/ios/LocalSample.ipa differ diff --git a/ios/appium_dotnet_driver_3_examples/local-test/LocalTest.cs b/ios/SampleLocalTest.cs similarity index 81% rename from ios/appium_dotnet_driver_3_examples/local-test/LocalTest.cs rename to ios/SampleLocalTest.cs index 777e8de..036c0ed 100644 --- a/ios/appium_dotnet_driver_3_examples/local-test/LocalTest.cs +++ b/ios/SampleLocalTest.cs @@ -1,16 +1,20 @@ -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; using OpenQA.Selenium.Appium; using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Support.UI; -namespace ios.local +namespace BrowserStack { - [TestFixture("local", "iphone-11-pro")] + [TestFixture] + [Category("sample-local-test")] public class LocalTest : BrowserStackNUnitTest { - public LocalTest(string profile, string environment) : base(profile,environment){ } + public LocalTest() : base() {} [Test] public void testLocal() @@ -19,11 +23,11 @@ public void testLocal() testButton.Click(); WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); - wait.Until(ExpectedConditions.TextToBePresentInElementValue(driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")), "Response is: Up and running")); + wait.Until(ExpectedConditions.TextToBePresentInElementValue(driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")), "Up and running")); IOSElement resultElement = (IOSElement)driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")); String resultString = resultElement.Text.ToLower(); - if(resultString.Contains("not working")) + if (resultString.Contains("not working")) { Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot(); string screenshot = ss.AsBase64EncodedString; diff --git a/ios/SampleTest.cs b/ios/SampleTest.cs new file mode 100644 index 0000000..5a541c4 --- /dev/null +++ b/ios/SampleTest.cs @@ -0,0 +1,28 @@ +using System; +using NUnit.Framework; +using OpenQA.Selenium.Appium; +using OpenQA.Selenium.Appium.iOS; +using OpenQA.Selenium.Support.UI; + +namespace BrowserStack +{ + [TestFixture] + [Category("sample-test")] + public class SampleTest : BrowserStackNUnitTest + { + public SampleTest() : base(){} + + [Test] + public void textVerificationTest() + { + IOSElement textButton = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button"))); + textButton.Click(); + + IOSElement textInput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input"))); + textInput.SendKeys("hello@browserstack.com" + "\n"); + + IOSElement textOutput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output"))); + Assert.That("hello@browserstack.com", Is.EqualTo(textOutput.Text)); + } + } +} diff --git a/ios/appium_dotnet_driver_3_examples/App.config b/ios/appium_dotnet_driver_3_examples/App.config deleted file mode 100644 index 03d857b..0000000 --- a/ios/appium_dotnet_driver_3_examples/App.config +++ /dev/null @@ -1,56 +0,0 @@ - - - - -
-
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ios/appium_dotnet_driver_3_examples/first-test/BrowserStackNUnitTest.cs b/ios/appium_dotnet_driver_3_examples/first-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 75f7924..0000000 --- a/ios/appium_dotnet_driver_3_examples/first-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -using NUnit.Framework; -using OpenQA.Selenium.Remote; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.iOS; -using System.Runtime.InteropServices; - -namespace ios.first -{ - public class BrowserStackNUnitTest - { - protected IOSDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - DesiredCapabilities capability = new DesiredCapabilities(); - - foreach (string key in caps.AllKeys) - { - capability.SetCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - capability.SetCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - capability.SetCapability("browserstack.user", username); - capability.SetCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - capability.SetCapability("app", appId); - } - - driver = new IOSDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - - } -} diff --git a/ios/appium_dotnet_driver_3_examples/first-test/FirstTest.cs b/ios/appium_dotnet_driver_3_examples/first-test/FirstTest.cs deleted file mode 100644 index 525bd02..0000000 --- a/ios/appium_dotnet_driver_3_examples/first-test/FirstTest.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using NUnit.Framework; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Support.UI; - -namespace ios.first -{ - [TestFixture("first", "iphone-11-pro")] - public class SingleTest : BrowserStackNUnitTest - { - public SingleTest(string profile, string environment) : base(profile, environment) { } - - [Test] - public void textVerificationTest() - { - IOSElement textButton = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button"))); - textButton.Click(); - - IOSElement textInput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input"))); - textInput.SendKeys("hello@browserstack.com"+"\n"); - - IOSElement textOutput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output"))); - Assert.AreEqual(textOutput.Text,"hello@browserstack.com"); - } - } -} diff --git a/ios/appium_dotnet_driver_3_examples/ios.csproj b/ios/appium_dotnet_driver_3_examples/ios.csproj deleted file mode 100644 index d14aa65..0000000 --- a/ios/appium_dotnet_driver_3_examples/ios.csproj +++ /dev/null @@ -1,73 +0,0 @@ - - - - Debug - AnyCPU - {94A16168-94B2-4047-866D-96611EBF5FA7} - Library - ios - ios - v4.6.1 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - - - true - bin\Release - prompt - 4 - - - - - - - packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll - - - packages\BrowserStackLocal.1.4.0\lib\net20\BrowserStackLocal.dll - - - packages\Selenium.WebDriver.3.6.0\lib\net45\WebDriver.dll - - - packages\Selenium.Support.3.6.0\lib\net45\WebDriver.Support.dll - - - packages\Castle.Core.3.3.3\lib\net45\Castle.Core.dll - - - packages\Appium.WebDriver.3.0.0.2\lib\net45\appium-dotnet-driver.dll - - - packages\NUnit.3.8.0\lib\net45\nunit.framework.dll - - - packages\System.Runtime.InteropServices.RuntimeInformation.4.0.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ios/appium_dotnet_driver_3_examples/ios.sln b/ios/appium_dotnet_driver_3_examples/ios.sln deleted file mode 100644 index e447988..0000000 --- a/ios/appium_dotnet_driver_3_examples/ios.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ios", "ios.csproj", "{94A16168-94B2-4047-866D-96611EBF5FA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {94A16168-94B2-4047-866D-96611EBF5FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {94A16168-94B2-4047-866D-96611EBF5FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {94A16168-94B2-4047-866D-96611EBF5FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {94A16168-94B2-4047-866D-96611EBF5FA7}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/ios/appium_dotnet_driver_3_examples/local-test/BrowserStackNUnitTest.cs b/ios/appium_dotnet_driver_3_examples/local-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 5922adb..0000000 --- a/ios/appium_dotnet_driver_3_examples/local-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,90 +0,0 @@ -using NUnit.Framework; -using OpenQA.Selenium.Remote; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.iOS; -using BrowserStack; -using System.Runtime.InteropServices; - -namespace ios.local -{ - public class BrowserStackNUnitTest - { - protected IOSDriver driver; - protected string profile; - protected string device; - private Local browserStackLocal; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - DesiredCapabilities capability = new DesiredCapabilities(); - - foreach (string key in caps.AllKeys) - { - capability.SetCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - capability.SetCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - capability.SetCapability("browserstack.user", username); - capability.SetCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - capability.SetCapability("app", appId); - } - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - && capability.GetCapability("browserstack.local") != null - && capability.GetCapability("browserstack.local").ToString() == "true") - { - browserStackLocal = new Local(); - List> bsLocalArgs = new List>() { - new KeyValuePair("key", accesskey) - }; - browserStackLocal.start(bsLocalArgs); - } - - driver = new IOSDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - if (browserStackLocal != null) - { - browserStackLocal.stop(); - } - } - - } -} diff --git a/ios/appium_dotnet_driver_3_examples/packages.config b/ios/appium_dotnet_driver_3_examples/packages.config deleted file mode 100644 index 7064519..0000000 --- a/ios/appium_dotnet_driver_3_examples/packages.config +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - diff --git a/ios/appium_dotnet_driver_3_examples/parallel-test/BrowserStackNUnitTest.cs b/ios/appium_dotnet_driver_3_examples/parallel-test/BrowserStackNUnitTest.cs deleted file mode 100644 index ae48169..0000000 --- a/ios/appium_dotnet_driver_3_examples/parallel-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,71 +0,0 @@ -using NUnit.Framework; -using OpenQA.Selenium.Remote; -using System; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.iOS; - -namespace ios.parallel -{ - public class BrowserStackNUnitTest - { - protected IOSDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - DesiredCapabilities capability = new DesiredCapabilities(); - - foreach (string key in caps.AllKeys) - { - capability.SetCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - capability.SetCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - capability.SetCapability("browserstack.user", username); - capability.SetCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - capability.SetCapability("app", appId); - } - - driver = new IOSDriver(new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"), capability); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - - } -} diff --git a/ios/appium_dotnet_driver_3_examples/parallel-test/ParallelTest.cs b/ios/appium_dotnet_driver_3_examples/parallel-test/ParallelTest.cs deleted file mode 100644 index 7f3cf95..0000000 --- a/ios/appium_dotnet_driver_3_examples/parallel-test/ParallelTest.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using System.Threading; -using System.Collections.ObjectModel; -using NUnit.Framework; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Support.UI; - -namespace ios.parallel -{ - [TestFixture("parallel", "iphone-11-pro")] - [TestFixture("parallel", "iphone-11-pro-max")] - [Parallelizable(ParallelScope.Fixtures)] - public class ParallelTest : BrowserStackNUnitTest - { - public ParallelTest(string profile, string device) : base(profile, device) {} - - [Test] - public void textVerificationTest() - { - IOSElement textButton = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button"))); - textButton.Click(); - - IOSElement textInput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input"))); - textInput.SendKeys("hello@browserstack.com"+"\n"); - - IOSElement textOutput = (IOSElement)new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output"))); - Assert.AreEqual(textOutput.Text,"hello@browserstack.com"); - } - } -} diff --git a/ios/appium_dotnet_driver_4_examples/App.config b/ios/appium_dotnet_driver_4_examples/App.config deleted file mode 100644 index 03d857b..0000000 --- a/ios/appium_dotnet_driver_4_examples/App.config +++ /dev/null @@ -1,56 +0,0 @@ - - - - -
-
-
- - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ios/appium_dotnet_driver_4_examples/first-test/BrowserStackNUnitTest.cs b/ios/appium_dotnet_driver_4_examples/first-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 703d6b4..0000000 --- a/ios/appium_dotnet_driver_4_examples/first-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Appium; - -namespace ios.first -{ - public class BrowserStackNUnitTest - { - protected IOSDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - //DesiredCapabilities capability = new DesiredCapabilities(); - AppiumOptions options = new AppiumOptions(); - - foreach (string key in caps.AllKeys) - { - options.AddAdditionalCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - options.AddAdditionalCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - options.AddAdditionalCapability("browserstack.user", username); - options.AddAdditionalCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - options.AddAdditionalCapability("app", appId); - } - - Uri uri = new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"); - driver = new IOSDriver(uri, options); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - - } -} diff --git a/ios/appium_dotnet_driver_4_examples/first-test/FirstTest.cs b/ios/appium_dotnet_driver_4_examples/first-test/FirstTest.cs deleted file mode 100644 index 2e1ee51..0000000 --- a/ios/appium_dotnet_driver_4_examples/first-test/FirstTest.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using NUnit.Framework; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Support.UI; - -namespace ios.first -{ - [TestFixture("first", "iphone-11-pro")] - public class SingleTest : BrowserStackNUnitTest - { - public SingleTest(string profile, string environment) : base(profile, environment) { } - - [Test] - public void textVerificationTest() - { - WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); - IOSElement textButton = (IOSElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button"))); - textButton.Click(); - - IOSElement textInput = (IOSElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input"))); - textInput.SendKeys("hello@browserstack.com"+"\n"); - - IOSElement textOutput = (IOSElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output"))); - Assert.AreEqual(textOutput.Text,"hello@browserstack.com"); - } - } -} diff --git a/ios/appium_dotnet_driver_4_examples/ios.csproj b/ios/appium_dotnet_driver_4_examples/ios.csproj deleted file mode 100644 index 7af901f..0000000 --- a/ios/appium_dotnet_driver_4_examples/ios.csproj +++ /dev/null @@ -1,80 +0,0 @@ - - - - - Debug - AnyCPU - {94A16168-94B2-4047-866D-96611EBF5FA7} - Library - ios - ios - v4.6.1 - - - true - full - false - bin\Debug - DEBUG; - prompt - 4 - - - true - bin\Release - prompt - 4 - - - - - - - packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll - - - packages\BrowserStackLocal.1.4.0\lib\net20\BrowserStackLocal.dll - - - packages\Selenium.WebDriver.3.141.0\lib\net45\WebDriver.dll - - - packages\Selenium.Support.3.141.0\lib\net45\WebDriver.Support.dll - - - packages\Castle.Core.4.4.1\lib\net45\Castle.Core.dll - - - packages\NUnit.3.12.0\lib\net45\nunit.framework.dll - - - packages\System.Runtime.InteropServices.RuntimeInformation.4.3.0\lib\net45\System.Runtime.InteropServices.RuntimeInformation.dll - - - packages\DotNetSeleniumExtras.PageObjects.3.11.0\lib\net45\SeleniumExtras.PageObjects.dll - - - packages\Appium.WebDriver.4.2.1\lib\net45\Appium.Net.dll - - - packages\DotNetSeleniumExtras.WaitHelpers.3.11.0\lib\net45\SeleniumExtras.WaitHelpers.dll - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ios/appium_dotnet_driver_4_examples/ios.sln b/ios/appium_dotnet_driver_4_examples/ios.sln deleted file mode 100644 index e447988..0000000 --- a/ios/appium_dotnet_driver_4_examples/ios.sln +++ /dev/null @@ -1,17 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ios", "ios.csproj", "{94A16168-94B2-4047-866D-96611EBF5FA7}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {94A16168-94B2-4047-866D-96611EBF5FA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {94A16168-94B2-4047-866D-96611EBF5FA7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {94A16168-94B2-4047-866D-96611EBF5FA7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {94A16168-94B2-4047-866D-96611EBF5FA7}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection -EndGlobal diff --git a/ios/appium_dotnet_driver_4_examples/local-test/BrowserStackNUnitTest.cs b/ios/appium_dotnet_driver_4_examples/local-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 90bf006..0000000 --- a/ios/appium_dotnet_driver_4_examples/local-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,92 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.iOS; -using BrowserStack; -using System.Runtime.InteropServices; -using OpenQA.Selenium.Appium; - -namespace ios.local -{ - public class BrowserStackNUnitTest - { - protected IOSDriver driver; - protected string profile; - protected string device; - private Local browserStackLocal; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - - AppiumOptions options = new AppiumOptions(); - - foreach (string key in caps.AllKeys) - { - options.AddAdditionalCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - options.AddAdditionalCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - options.AddAdditionalCapability("browserstack.user", username); - options.AddAdditionalCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - options.AddAdditionalCapability("app", appId); - } - - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) - && options.ToCapabilities().HasCapability("browserstack.local") - && options.ToCapabilities().GetCapability("browserstack.local").ToString() == "true") - { - browserStackLocal = new Local(); - List> bsLocalArgs = new List>() { - new KeyValuePair("key", accesskey) - }; - browserStackLocal.start(bsLocalArgs); - } - - Uri uri = new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"); - driver = new IOSDriver(uri, options); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - if (browserStackLocal != null) - { - browserStackLocal.stop(); - } - } - - } -} diff --git a/ios/appium_dotnet_driver_4_examples/local-test/LocalTest.cs b/ios/appium_dotnet_driver_4_examples/local-test/LocalTest.cs deleted file mode 100644 index c64a419..0000000 --- a/ios/appium_dotnet_driver_4_examples/local-test/LocalTest.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using NUnit.Framework; -using OpenQA.Selenium; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Support.UI; - -namespace ios.local -{ - [TestFixture("local", "iphone-11-pro")] - public class LocalTest : BrowserStackNUnitTest - { - public LocalTest(string profile, string environment) : base(profile,environment){ } - - [Test] - public void testLocal() - { - WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); - IOSElement testButton = (IOSElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal"))); - testButton.Click(); - - wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.TextToBePresentInElementValue(driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")), "Response is: Up and running")); - IOSElement resultElement = (IOSElement)driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")); - - String resultString = resultElement.Text.ToLower(); - if(resultString.Contains("not working")) - { - Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot(); - string screenshot = ss.AsBase64EncodedString; - byte[] screenshotAsByteArray = ss.AsByteArray; - ss.SaveAsFile("screenshot", ScreenshotImageFormat.Png); - ss.ToString(); - } - - String expectedString = "Up and running"; - - Assert.True(resultString.Contains(expectedString.ToLower())); - } - } -} diff --git a/ios/appium_dotnet_driver_4_examples/packages.config b/ios/appium_dotnet_driver_4_examples/packages.config deleted file mode 100644 index ebee1bc..0000000 --- a/ios/appium_dotnet_driver_4_examples/packages.config +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/ios/appium_dotnet_driver_4_examples/parallel-test/BrowserStackNUnitTest.cs b/ios/appium_dotnet_driver_4_examples/parallel-test/BrowserStackNUnitTest.cs deleted file mode 100644 index 18b6b6c..0000000 --- a/ios/appium_dotnet_driver_4_examples/parallel-test/BrowserStackNUnitTest.cs +++ /dev/null @@ -1,72 +0,0 @@ -using NUnit.Framework; -using System; -using System.Collections.Specialized; -using System.Configuration; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Appium; - -namespace ios.parallel -{ - public class BrowserStackNUnitTest - { - protected IOSDriver driver; - protected string profile; - protected string device; - - public BrowserStackNUnitTest(string profile, string device) - { - this.profile = profile; - this.device = device; - } - - [SetUp] - public void Init() - { - NameValueCollection caps = ConfigurationManager.GetSection("capabilities/" + profile) as NameValueCollection; - NameValueCollection devices = ConfigurationManager.GetSection("environments/" + device) as NameValueCollection; - - AppiumOptions options = new AppiumOptions(); - - foreach (string key in caps.AllKeys) - { - options.AddAdditionalCapability(key, caps[key]); - } - - foreach (string key in devices.AllKeys) - { - options.AddAdditionalCapability(key, devices[key]); - } - - String username = Environment.GetEnvironmentVariable("BROWSERSTACK_USERNAME"); - if (username == null) - { - username = ConfigurationManager.AppSettings.Get("user"); - } - - String accesskey = Environment.GetEnvironmentVariable("BROWSERSTACK_ACCESS_KEY"); - if (accesskey == null) - { - accesskey = ConfigurationManager.AppSettings.Get("key"); - } - - options.AddAdditionalCapability("browserstack.user", username); - options.AddAdditionalCapability("browserstack.key", accesskey); - - String appId = Environment.GetEnvironmentVariable("BROWSERSTACK_APP_ID"); - if (appId != null) - { - options.AddAdditionalCapability("app", appId); - } - - Uri uri = new Uri("http://" + ConfigurationManager.AppSettings.Get("server") + "/wd/hub/"); - driver = new IOSDriver(uri, options); - } - - [TearDown] - public void Cleanup() - { - driver.Quit(); - } - - } -} diff --git a/ios/appium_dotnet_driver_4_examples/parallel-test/ParallelTest.cs b/ios/appium_dotnet_driver_4_examples/parallel-test/ParallelTest.cs deleted file mode 100644 index b7e3b10..0000000 --- a/ios/appium_dotnet_driver_4_examples/parallel-test/ParallelTest.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; -using NUnit.Framework; -using OpenQA.Selenium.Appium; -using OpenQA.Selenium.Appium.iOS; -using OpenQA.Selenium.Support.UI; - -namespace ios.parallel -{ - [TestFixture("parallel", "iphone-11-pro")] - [TestFixture("parallel", "iphone-11-pro-max")] - [Parallelizable(ParallelScope.Fixtures)] - public class ParallelTest : BrowserStackNUnitTest - { - public ParallelTest(string profile, string device) : base(profile, device) {} - - [Test] - public void textVerificationTest() - { - WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30)); - IOSElement textButton = (IOSElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Button"))); - textButton.Click(); - - IOSElement textInput = (IOSElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Input"))); - textInput.SendKeys("hello@browserstack.com"+"\n"); - - IOSElement textOutput = (IOSElement) wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("Text Output"))); - Assert.AreEqual(textOutput.Text,"hello@browserstack.com"); - } - } -} diff --git a/ios/browserstack.yml b/ios/browserstack.yml new file mode 100644 index 0000000..66a53a6 --- /dev/null +++ b/ios/browserstack.yml @@ -0,0 +1,67 @@ +# ============================= +# Set BrowserStack Credentials +# ============================= +# Add your BrowserStack userName and acccessKey here or set BROWSERSTACK_USERNAME and +# BROWSERSTACK_ACCESS_KEY as env variables +userName: BROWSERSTACK_USERNAME +accessKey: BROWSERSTACK_ACCESS_KEY + +# ====================== +# BrowserStack Reporting +# ====================== +# The following capabilities are used to set up reporting on BrowserStack: +# Set 'projectName' to the name of your project. Example, Marketing Website +projectName: BrowserStack Samples +# Set `buildName` as the name of the job / testsuite being run +buildName: browserstack build +# `buildIdentifier` is a unique id to differentiate every execution that gets appended to +# buildName. Choose your buildIdentifier format from the available expressions: +# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution +# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30 +# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests +buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression} + +source: 'nunit:appium-sample-sdk:v1.0' + +# Set `app` to define the app that is to be used for testing. +# It can either take the id of any uploaded app or the path of the app directly. +app: ./BStackSampleApp.ipa +# app: ./LocalSample.ipa #For running local tests + +# ======================================= +# Platforms (Browsers / Devices to test) +# ======================================= +# Platforms object contains all the browser / device combinations you want to test on. +# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate) + +platforms: + - deviceName: iPhone 14 Pro + osVersion: 16 + platformName: ios + - deviceName: iPhone 13 Pro + osVersion: 15 + platformName: ios + - deviceName: iPhone XS + osVersion: 14 + platformName: ios + +# ========================================== +# BrowserStack Local +# (For localhost, staging/private websites) +# ========================================== +# Set browserStackLocal to true if your website under test is not accessible publicly over the internet +# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction +browserstackLocal: true # (Default false) +#browserStackLocalOptions: +#Options to be passed to BrowserStack local in-case of advanced configurations +# localIdentifier: # (Default: null) Needed if you need to run multiple instances of local. +# forceLocal: true # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel. +# Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections + +# =================== +# Debugging features +# =================== +debug: false # # Set to true if you need screenshots for every selenium command ran +networkLogs: false # Set to true to enable HAR logs capturing +consoleLogs: errors # Remote browser's console debug levels to be printed (Default: errors) +# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors) diff --git a/ios/ios.csproj b/ios/ios.csproj new file mode 100644 index 0000000..832e7d0 --- /dev/null +++ b/ios/ios.csproj @@ -0,0 +1,19 @@ + + + + net6.0 + BrowserStack + enable + enable + + + + + + + + + + + + diff --git a/nunit-appium-app-browserstack.sln b/nunit-appium-app-browserstack.sln new file mode 100644 index 0000000..97cd5f9 --- /dev/null +++ b/nunit-appium-app-browserstack.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1705.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "android", "android\android.csproj", "{C99ED549-46BC-42FD-B177-6E9AE6060359}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ios", "ios\ios.csproj", "{7C691BCB-F541-43C6-9746-4BABB262C24A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C99ED549-46BC-42FD-B177-6E9AE6060359}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C99ED549-46BC-42FD-B177-6E9AE6060359}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C99ED549-46BC-42FD-B177-6E9AE6060359}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C99ED549-46BC-42FD-B177-6E9AE6060359}.Release|Any CPU.Build.0 = Release|Any CPU + {7C691BCB-F541-43C6-9746-4BABB262C24A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C691BCB-F541-43C6-9746-4BABB262C24A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C691BCB-F541-43C6-9746-4BABB262C24A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C691BCB-F541-43C6-9746-4BABB262C24A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7B9E5D13-0DEA-4DE3-AD97-66F337C9CFDC} + EndGlobalSection +EndGlobal