Simulate Geolocation

If your website serves different content based on the country your end-users live in, you will want to test that functionality. You can use the browserstack.geoLocation capability to test your websites across different countries using BrowserStack’s IP Geolocation feature.

Capability Description Expected values
browserstack.geoLocation The country you want your test to detect A string. An ISO 2 country code

FR for France,
CN for China

See the list of 45+ countries we support

Here is the sample code that sets the geolocation to France:

// Testing with the IP geolocation set to France

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("browserstack.geoLocation", "FR");
// ... other capabilities
// Testing with the IP geolocation set to France

var capabilities = {
 "browserstack.geoLocation" : "FR"
  // ... other capabilities
}
// Testing with the IP geolocation set to France

DesiredCapabilities caps = new DesiredCapabilities();
caps.SetCapability("browserstack.geoLocation", "FR");
// ... other capabilities
# Testing with the IP geolocation set to France

$caps = array(
 "browserstack.geoLocation" => "FR"
 # ... other capabilities
);
# Testing with the IP geolocation set to France

capabilities = {
 "browserstack.geoLocation" : "FR"
 # ... other capabilities
}
# Testing with the IP geolocation set to France

caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.geoLocation"] = "FR"
# ... other capabilities

Note: This feature only sets the IP to the selected geolocation, and not guaranteed to set the appropriate timezone. If you want to use the timezone in that country, you will have to configure a custom timezone.

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