I'm trying to get Appium WebDriver integrated with BrowserStack, using C# behind a corporate proxy server and am having trouble.

I'm using CNTLM due to the proxy server, so am trying to point Appium at a localhost address but it's not setting up the driver correctly. Everything I've tried hits the proxy server and comes back with an error due to lack of authentication, which suggests it's not going through CNTLM properly.

I've been able to get the Appium Desktop application working with BrowserStack. The same local proxy address works fine here, which suggests it's an incorrect/missing setting at the code level.

Here is my C# code

    using System;
    using NUnit.Framework;
    using OpenQA.Selenium;
    using OpenQA.Selenium.Appium;
    using OpenQA.Selenium.Appium.Android;

    namespace AppiumProxySetup
        public class UnitTest1
            readonly static string userName = "<username>";
            readonly static string accessKey = "<accessKey>";
            readonly static Uri browserStackAddress = new Uri("https://hub-cloud.browserstack.com:443/wd/hub");
            readonly static string proxyAddress = "<default CNTLM local address and port>";

            private AndroidDriver<AndroidElement> driver;
            private Proxy proxySettings = new Proxy();

            public void Setup()
                proxySettings.FtpProxy = proxyAddress;
                proxySettings.HttpProxy = proxyAddress;
                proxySettings.SslProxy = proxyAddress;
                proxySettings.Kind = ProxyKind.Manual;

                AppiumOptions options = new AppiumOptions();
                options.AddAdditionalCapability("browserstack.user", userName);
                options.AddAdditionalCapability("browserstack.key", accessKey);
                options.AddAdditionalCapability("device", "Google Pixel");
                options.AddAdditionalCapability("os_version", "8.0");
                options.AddAdditionalCapability("name", "Sample Test");
                options.AddAdditionalCapability("app", "<app id>");
                options.AddAdditionalCapability("realMobile", true);
                options.Proxy = proxySettings;
                options.AddAdditionalCapability("proxy", options.Proxy);

                driver = new AndroidDriver<AndroidElement>(browserStackAddress, options);

            public void SimpleTest()
                AndroidElement searchElement = driver.FindElementByAccessibilityId("<id>");

            public void Teardown()
                if (driver != null)


Every time I run the test, 'driver' appears to be null due to, I think, the proxy server not allowing the request out.

As an aside, I'm using Appium v4.0.0.6-beta and VS2015, NUnit3 and latest Selenium.

Any help would be much appreciated!



Managed to bypass the issue by disabling the URL filter on the proxy server (which then meant I didn't need any of the CNTLM elements for this to work). Test runs now appear on the BrowserStack dashboard.

Despite this, I'd be interested to know if someone in this situation has gotten this working without having to resort to amending firewall settings.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.