Skip to main content
Transform your testing process with: Real Device Features, Company-wide Licences, & App Percy

Simulate GPS location

GPS Geolocation testing enables you to simulate the location of the device to specific GPS coordinates in order to test location-based scenarios for your app.

Use the GPS location capability as shown in the following code sinppets to specify the GPS coordinates. You will be required to pass the latitude and longitude of the desired location.

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

Capability Description Value
gpsLocation Simulate the location of the device to a specific GPS location. Latitude followed by longitude

Acceptable range for latitude is -90 to +90 and for longitude is -180 to +180.

Example: “40.730610,-73.935242”
browserstack.yml
Copy icon Copy snippet

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.

Use the following code snippet to set the GPS location

Capability Description Value
gpsLocation Simulate the location of the device to a specific GPS location. Latitude followed by longitude

Acceptable range for latitude is -90 to +90 and for longitude is -180 to +180.

Example: “40.730610,-73.935242”

Example:

DesiredCapabilities capabilities = new DesiredCapabilities();
HashMap<String, Object> browserstackOptions = new HashMap<String, Object>();
browserstackOptions.put("gpsLocation", "-73.935242,40.730610");
var capabilities = {
	'bstack:options' : {
		"gpsLocation" : "-73.935242,40.730610",
		},
}
AppiumOptions capabilities = new AppiumOptions();
Dictionary<string, object> browserstackOptions = new Dictionary<string, object>();
browserstackOptions.Add("gpsLocation", "-73.935242,40.730610");
$caps = array(
    'bstack:options' => array(
        "gpsLocation" => "-73.935242,40.730610",
    ),
)
desired_cap = {
	'bstack:options' : {
		"gpsLocation" : "-73.935242,40.730610",
	},
}
capabilities = {
    'bstack:options' => {
        "gpsLocation" => "-73.935242,40.730610",
    },
}
Capability Description Value
browserstack.gpsLocation Simulate the location of the device to a specific GPS location. Latitude followed by longitude

Acceptable range for latitude is -90 to +90 and for longitude is -180 to +180.

Example: “40.730610,-73.935242”

Example:

DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
capabilities.setCapability("browserstack.gpsLocation", "-73.935242,40.730610");
var capabilities = {
	"browserstack.gpsLocation" : "-73.935242,40.730610",
}
AppiumOptions capabilities = new AppiumOptions();
capabilities.AddAdditionalCapability("browserstack.gpsLocation", "-73.935242,40.730610");
$caps = array(
"browserstack.gpsLocation" => "-73.935242,40.730610"
)
desired_cap = {
"browserstack.gpsLocation" : "-73.935242,40.730610"
}
caps = Selenium::WebDriver::Remote::Capabilities.new
caps["browserstack.gpsLocation"] = "-73.935242,40.730610"

GPS location feature for app testing is only available with a BrowserStack Paid plan. View details.

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