As of STP 41, safaridriver has added new capabilites and extension commands to better support testing WebRTC via WebDriver.
All API described here is considered experimental and is subject to change as we receive early feedback. It is available for testing using safaridriver included with Safari Technology Preview Release 41. More detailed information, with examples, will be disseminated in an upcoming webkit.org blog post.
This is an excerpt from the safaridriver manpage in trunk which reflects support in STP 41.
webkit:WebRTC
This capability allows a test to temporarily change Safari's policies for
WebRTC and Media Capture. The value of the webkit:WebRTC capability is a dic-
tionary with the following sub-keys, all of which are optional:
DisableInsecureMediaCapture
Normally, Safari refuses to allow media capture over insecure connec-
tions. This capability suppresses that restriction for testing purposes.
For example, it would allow a test to exercise media capture code paths
using a local test web server that is not configured to use HTTPS.
DisableICECandidateFiltering
To protect a user's privacy, Safari normally filters out WebRTC ICE can-
didates that correspond to internal network addresses when capture
devices are not in use. This capability suppresses ICE candidate filter-
ing so that both internal and external network addresses are always sent
as ICE candidates.
The following is very basic documentation of extension commands for getting/setting user permissions. Bindings support for these commands will be proposed in a pull request soon(tm).
Endpoint template: GET /session/$sessionId/apple/permissions
JSON arguments: none
JSON result: { “permissions”: { permissionName: true, otherPermission: false, […] } }
- top level key “permissions” with value of type Object.
- Known permission names and values are stored and key-value pairs in the “permissions” object. Description: This command returns the names and values of all permissions that have been temporarily set for the session.
Endpoint template: POST /session/$sessionId/apple/permissions
JSON arguments: { “permissions”: { permissionName: true, otherPermission: false, […] } }
- top level key “permissions” with value of type Object.
- Permission names and requested values are stored and key-value pairs in the “permissions” object.
JSON result: none
Description: This command sets the values for the mentioned session permissions. If a permission name is not supported by safaridriver or the particular session, then that permission is ignored and this command has no effect on it.
- “GetUserMedia”: this permission controls whether getUserMedia() requests should be accepted or denied
automatically. The accepted values are
true
andfalse
(JS literals, not strings). The default value is to accept these requests, since only mock media capture devices are available to pages associated with an automation session.