Simulate Geolocation
Learn how to simulate the location of browsers using the IP Geolocation feature for your Playwright tests.
Introduction
BrowserStack’s IP geolocation feature allows you to simulate website behavior from different locations using IP addresses hosted in 45+ countries around the world. By incorporating IP geolocation into your tests, you can verify scenarios such as localized pricing, languages, product listings, and so on.
With IP geolocation enabled, traffic from your web app will originate from an IP address hosted in the country you have selected.
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 |
Set the geolocation capability
Add the geoLocation
key and the country code within the capabilities as shown in the following code snippet:
//sample_test.js
const caps = {
'browserstack.geoLocation' : 'FR'
};
...
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!