Test on Internal Networks
BrowserStack enables you to run your SpecFlow 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 SpecFlow tests for Local Testing takes just three steps:
-
Download and run the BrowserStackLocal binary:
Note: Install BrowserstackLocal using NuGet Gallery
-
Now, you need to update your SpecFlow config file and set the
browserstack.local
capability totrue
:<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" /> <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> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" /></startup><specFlow> <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --> <!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --><unitTestProvider name="NUnit" /></specFlow></configuration>
Here is a sample feature and steps file which using Local Testing:
// Local Feature Feature: Local Scenario Outline: Can check tunnel working Given I opened health check for <profile> and <environment> Then I should see "Up and running" Examples: | profile | environment | | local | chrome |
// Local Steps [Binding] public class LocalSteps { private IWebDriver _driver; readonly BrowserStackDriver _bsDriver; public LocalSteps(ScenarioContext scenarioContext) { _bsDriver = (BrowserStackDriver)scenarioContext["bsDriver"]; } [Given(@"I opened health check for (.*) and (.*)")] public void GivenIOpenedHealthCheck(string profile, string environment) { _driver = _bsDriver.Init(profile, environment); _driver.Navigate().GoToUrl("http://bs-local.com:45691/check"); } [Then(@"I should see ""(.*)""")] public void ThenIShouldSee(string body) { Assert.That(_driver.PageSource, Does.Contain(body)); } }
-
You can now run your SpecFlow test using BrowserStack Local with the following command:
Build the solution in Visual Studio 2015 Update 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
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!