Test on Internal Networks

BrowserStack enables you to run your NUnit automated tests on your internal development environments, on localhost, and from behind a corporate firewall. This feature is called “Local Testing”.

Local Testing establishes a secure connection between your machine and the BrowserStack cloud. Once you set up Local Testing, all URLs work out of the box, including HTTPS URLs and those behind a proxy or firewall.

Configuring your NUnit tests for Local Testing takes just three steps:

  1. Clone the nunit-browserstack repo on GitHub with BrowserStack’s sample test, using the following command (if not already done):

     git clone https://github.com/browserstack/nunit-browserstack.git
    
  2. Open the solution NUnit-BrowserStack.sln in Visual Studio.

  3. Next, you need to update your NUnit config file, App.config, and set you credentials and the browserstack.local capability to true:

     <?xml version="1.0" encoding="utf-8" ?>
     <configuration>
       <configSections>
         <sectionGroup name="capabilities">
           <section name="local" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
         </sectionGroup>
    
         <sectionGroup name="environments">
           <section name="chrome" type="System.Configuration.AppSettingsSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
         </sectionGroup>
       </configSections>
    
       <appSettings>
         <add key="user" value="YOUR_USERNAME" />
         <add key="key" value="YOUR_ACCESS_KEY" />
         <add key="server" value="hub-cloud.browserstack.com" />
       </appSettings>
    
       <capabilities>
         <local>
           <add key="browserstack.local" value="true" />
         </local>
       </capabilities>
    
       <environments>
         <chrome>
           <add key="browser" value="chrome" />
         </chrome>
       </environments>
     </configuration>
    
  4. Run a sample test case to check whether the Local test connection has been setup properly. You can use the following sample test case, which can be found in the repo under nunit-browserstack/NUnit-BrowserStack/ directory:

    LocalTest.cs
     [TestFixture("local", "chrome")]
     public class LocalTest : BrowserStackNUnitTest
     {
       public LocalTest(string profile, string environment) : base(profile, environment) { }
    
       [Test]
       public void HealthCheck()
       {
         driver.Navigate().GoToUrl("http://bs-local.com:45691/check");
         Assert.IsTrue(Regex.IsMatch(driver.PageSource, "Up and running", RegexOptions.IgnoreCase));
       }
     }
    
  5. You can now run your NUnit test using BrowserStack Local with the following steps:

    1. Build the solution in Visual Studio
    2. Run test with fixture local from Test Explorer

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better







Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked






Thank you for your valuable feedback!

Talk to an Expert
Talk to an Expert