Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & Test Observability
No Result Found

Simulate Geolocation

Simulate location of browsers and devices using IP Geo-location on BrowserStack Automate

IP Geolocation is an Enterprise-only feature. You can contact sales to get an Enterprise plan for your account.

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 geolocation capability to test your websites across different countries using BrowserStack’s IP Geolocation feature.

If you are using BrowserStack SDK, you can set the following capabilities in the browserstack.yml file:

Capability Description Expected values
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
browserstack.yml
Copy icon Copy

BrowserStack SDK is a plug-n-play solution that takes care of all the integration steps for you. Using the BrowserStack SDK is the recommended integration method for your project. To know more, visit the SDK core concepts page.

Capability Description Expected values
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

MutableCapabilities capabilities = new MutableCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("geoLocation", "FR");
capabilities.setCapability("bstack:options", browserstackOptions);
// ... other capabilities
// Testing with the IP geolocation set to France

var capabilities = {
'bstack:options' : {
"geoLocation" : "FR",
}
}

// Testing with the IP geolocation set to France

Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("geoLocation", "FR");
capabilities.AddAdditionalOption("bstack:options", browserstackOptions);
// ... other capabilities
# Testing with the IP geolocation set to France
$caps = array(
'bstack:options' => array(
"geoLocation" => "FR",
),
)
# Testing with the IP geolocation set to France
desired_cap = {
'bstack:options' : {
"geoLocation" : "FR",
},
}
# Testing with the IP geolocation set to France
capabilities = {
'bstack:options' => {
"geoLocation" => "FR",
},
}

# ... other capabilities
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
# Testing with the IP geolocation set to France

my $capabilities = {
 "browserstack.networkLogs" => "true"
 # ... 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

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
Download Copy Check Circle