Class SetGeolocation
java.lang.Object
net.serenitybdd.screenplay.playwright.interactions.SetGeolocation
- All Implemented Interfaces:
net.serenitybdd.core.SkipNested,net.serenitybdd.screenplay.Performable
Set the browser's geolocation for testing location-based features.
Sample usage:
// Set specific coordinates
actor.attemptsTo(SetGeolocation.to(51.5074, -0.1278)); // London
// Set with accuracy
actor.attemptsTo(SetGeolocation.to(40.7128, -74.0060).withAccuracy(100)); // New York
// Use predefined locations
actor.attemptsTo(SetGeolocation.toNewYork());
actor.attemptsTo(SetGeolocation.toLondon());
actor.attemptsTo(SetGeolocation.toTokyo());
// Clear geolocation
actor.attemptsTo(SetGeolocation.clear());
Note: You must also grant the 'geolocation' permission for this to work.
See GrantPermissions.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic SetGeolocationclear()Clear the geolocation override.<T extends net.serenitybdd.screenplay.Actor>
voidperformAs(T actor) static SetGeolocationto(double latitude, double longitude) Set geolocation to the specified coordinates.static SetGeolocationtoLondon()Set geolocation to London.static SetGeolocationSet geolocation to New York City.static SetGeolocationtoParis()Set geolocation to Paris.static SetGeolocationSet geolocation to San Francisco.static SetGeolocationtoSydney()Set geolocation to Sydney.static SetGeolocationtoTokyo()Set geolocation to Tokyo.withAccuracy(double accuracy) Set the accuracy of the geolocation in meters.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.serenitybdd.screenplay.Performable
then
-
Method Details
-
to
Set geolocation to the specified coordinates.- Parameters:
latitude- Latitude between -90 and 90longitude- Longitude between -180 and 180
-
clear
Clear the geolocation override. -
toNewYork
Set geolocation to New York City. -
toLondon
Set geolocation to London. -
toTokyo
Set geolocation to Tokyo. -
toSanFrancisco
Set geolocation to San Francisco. -
toSydney
Set geolocation to Sydney. -
toParis
Set geolocation to Paris. -
withAccuracy
Set the accuracy of the geolocation in meters.- Parameters:
accuracy- Accuracy in meters (default is 0)
-
performAs
public <T extends net.serenitybdd.screenplay.Actor> void performAs(T actor) - Specified by:
performAsin interfacenet.serenitybdd.screenplay.Performable
-