2

My site has different behaviour depending on user details (such as location...), the way i test this manually is by browsing the site using proxies, is this testing doable using Browserstack?

In other words can i specify a proxy for Browserstack to use when browsing my site?

Youssef
  • 1,033
  • 8
  • 16

2 Answers2

4

Yes, you need to setup BrowserStack Local Testing. You can use these parameters while using the command line binaries.

  1. -proxyHost HOST - Hostname/IP address of the proxy server. If this flag is not set, the remaining proxy options are ignored.
  2. -proxyPort PORT - Port for the proxy server. Defaults to 3128.
  3. -proxyUser USERNAME - Username for connecting to the proxy server (Basic Auth only).
  4. -proxyPass PASSWORD - Password for connecting to the proxy server (Basic Auth only). If the -proxyUser flag is not set, -proxyPass will be ignored.

For more information, refer BrowserStack's documentation

nidhimj22
  • 435
  • 1
  • 4
  • 14
1

You need to open command prompt and use this command : BrowserStackLocal.exe -proxyHost 2.2.2.2 -proxyPort 8080 -proxyUser xyz -proxyPass sksk -forcelocal xyz

You can use this simple code for learning purpose :

public static final String USERNAME = "xyz";
public static final String AUTOMATE_KEY = "xyz";
public static final String URL = "http://" + USERNAME + ":" + AUTOMATE_KEY + "@hub.browserstack.com/wd/hub";
public static void main(String[] args) throws Exception
{
      DesiredCapabilities caps = new DesiredCapabilities();
      System.setProperty("java.net.useSystemProxies", "true");
      System.setProperty("http.proxyHost","2.2.2.2");
      System.setProperty("http.proxyPort","8080");
      System.setProperty("http.proxyUser","xyz");
      System.setProperty("http.proxyPass","xyz");
      caps.setCapability("browser", "FireFox");
      caps.setCapability("browser_version", "40.0");
      caps.setCapability("os", "Windows");
      caps.setCapability("browserstack.debug", "true");
      caps.setCapability("browserstack.local", "true"); 
      WebDriver driver = new RemoteWebDriver(new URL(URL), caps);
      driver.get("http://www.google.com");
      WebElement element = driver.findElement(By.name("q"));
      element.sendKeys("BrowserStack");
      element.submit();
      System.out.println(driver.getTitle());
      driver.quit();
}
user3251882
  • 922
  • 1
  • 11
  • 21