DesiredCapabilities For Safari Extensions

59 views
Skip to first unread message

confusa

unread,
Jul 7, 2014, 1:24:06 PM7/7/14
to seleniu...@googlegroups.com
Trying to load a specific Safari extension using RemoteWebDriver like so:

capabilities.setCapability("extensions", new String[] { "ZoomBySite.safariextz" });

In the logs I can see it creating the browser session with that capability, but the extension is not being loaded. What am I doing incorrectly?

TIA


David

unread,
Jul 8, 2014, 3:19:02 PM7/8/14
to seleniu...@googlegroups.com
I think you may be mistaken on the process to do this. It might be simplified when using the Java bindings (or C#) since those typically wrap some of the functionality for the user vs other language bindings or vs using pure RemoteWebDriver (over say SafariDriver) to work with Safari.


you do pass in a string array of extensions but for the values, "Each extension should be specified as the base64 encoding of a .safariextz file". Which means you have to read in the safariextz file as binary data then do a base64 conversion to make it a string then pass that in an array as desired capabilities.

Existing firefox profiles (which can contain extensions in them already) are passed the same way as base64 string (of a zip file of the profile directory)

confusa

unread,
Jul 11, 2014, 4:57:51 PM7/11/14
to seleniu...@googlegroups.com
Yeah, I saw that bit in the Wiki but sort of glossed over the encoding part. So I tried this but still not loading the extension:

Path path = Paths.get("temp/ZoomBySite.safariextz");
byte[] encodedBytes = null;
try {
            byte[] bytes = Files.readAllBytes(path);
            encodedBytes = Base64.encodeBase64(bytes);
        } catch (IOException e) {
            e.printStackTrace();
        }
capabilities.setCapability("extensions", new String[] { encodedBytes.toString() });

David

unread,
Jul 12, 2014, 10:50:55 PM7/12/14
to seleniu...@googlegroups.com
Sorry, I've not worked with Safari extensions with WebDriver. I suggest you file a bug and let it proceed from there. Since there doesn't seem to be any other replies to this thread.
Reply all
Reply to author
Forward
0 new messages