Class GrantPermissions
java.lang.Object
net.serenitybdd.screenplay.playwright.interactions.GrantPermissions
- All Implemented Interfaces:
net.serenitybdd.core.SkipNested,net.serenitybdd.screenplay.Performable
Grant browser permissions for testing features that require user consent.
Sample usage:
// Grant single permission
actor.attemptsTo(GrantPermissions.for_("geolocation"));
// Grant multiple permissions
actor.attemptsTo(GrantPermissions.for_("geolocation", "notifications", "camera"));
// Grant permissions for specific origin
actor.attemptsTo(
GrantPermissions.for_("clipboard-read", "clipboard-write")
.onOrigin("https://example.com")
);
// Use predefined permission sets
actor.attemptsTo(GrantPermissions.forGeolocation());
actor.attemptsTo(GrantPermissions.forNotifications());
actor.attemptsTo(GrantPermissions.forMediaDevices());
Available permissions include:
- geolocation
- notifications
- camera
- microphone
- clipboard-read
- clipboard-write
- payment-handler
- midi
- midi-sysex
- ambient-light-sensor
- accelerometer
- gyroscope
- magnetometer
- accessibility-events
- background-sync
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic GrantPermissionsGrant the specified permissions.static GrantPermissionsGrant clipboard read and write permissions.static GrantPermissionsGrant geolocation permission.static GrantPermissionsGrant camera and microphone permissions for media access.static GrantPermissionsGrant notifications permission.Restrict the permissions to a specific origin.<T extends net.serenitybdd.screenplay.Actor>
voidperformAs(T actor) 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
-
for_
Grant the specified permissions. Note: Using "for_" to avoid conflict with Java reserved word "for".- Parameters:
permissions- The permissions to grant
-
forGeolocation
Grant geolocation permission. -
forNotifications
Grant notifications permission. -
forMediaDevices
Grant camera and microphone permissions for media access. -
forClipboard
Grant clipboard read and write permissions. -
onOrigin
Restrict the permissions to a specific origin.- Parameters:
origin- The origin URL (e.g., "https://example.com")
-
performAs
public <T extends net.serenitybdd.screenplay.Actor> void performAs(T actor) - Specified by:
performAsin interfacenet.serenitybdd.screenplay.Performable
-