Firefox, specifying profile, using JsonWireProtocol?

852 views
Skip to first unread message

Darren Cook

unread,
Sep 8, 2011, 9:15:26 AM9/8/11
to webd...@googlegroups.com
I asked a selenium question here:

http://stackoverflow.com/questions/7328494/selenium2-firefox-use-the-default-profile

Is it correct that the java code example shown (for specifying the
firefox profile to use) is being turned into JsonWireProtocol commands?
If so, that is great. But can someone tell me the actual web service
commands being used? I can then implement this in the PHP library.

(Responses as to why my various attempts to specify the firefox profile
failed are also warmly welcome. Here or on StackOverflow, either is fine
by me :-)

Thanks,

Darren

--
Darren Cook, Software Researcher/Developer

http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)

Simon Stewart

unread,
Sep 9, 2011, 8:00:38 AM9/9/11
to webd...@googlegroups.com
The wire protocol is documented here:

http://code.google.com/p/selenium/wiki/JsonWireProtocol

When transmitting the profile, we first zip up the profile then base64
encode that.

Simon

> --
> You received this message because you are subscribed to the Google Groups "webdriver" group.
> To post to this group, send email to webd...@googlegroups.com.
> To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.
>
>

Darren Cook

unread,
Sep 9, 2011, 9:55:05 AM9/9/11
to webd...@googlegroups.com
> The wire protocol is documented here:
> http://code.google.com/p/selenium/wiki/JsonWireProtocol
>
> When transmitting the profile, we first zip up the profile then base64
> encode that.

Hello Simon,
Thanks for the reply. So I actually send the whole "default" profile
directory over http and then Selenium will recreate that under another
directory name next to my existing "default"? Interesting. Nice way to
avoid corrupting my real profiles, which I can see would be ideal for
unit testing. [1]

As I can't see it documented in the above URL, could you tell me exactly
how the profile is sent? I assume it is a parameter of the /session
command [2]. Is it a top-level parameter (e.g. called "profile"
perhaps?) Or is it a key in the desiredCapabilities parameter [3]? Or
something else?

Also, by "zip up"... this means what the windows or unix "zip" command
does? Or does it mean using tar and gzip?

Thanks,

Darren


[1] I'd still like a way to specify to use an existing profile, as when
using Selenium for browser automation rather than unit testing this can
be more useful (e.g. if I want to create bookmarks, or fill the browser
cache, or even simply leave the cookies intact so I can manually browse
a website at the end of the automated part); but by the sounds of all
the answers I've got, this is not a feature at the moment.

[2]: http://code.google.com/p/selenium/wiki/JsonWireProtocol#/session

[3]:
http://code.google.com/p/selenium/wiki/JsonWireProtocol#Desired_Capabilities


>> I asked a selenium question here:
>>
>> http://stackoverflow.com/questions/7328494/selenium2-firefox-use-the-default-profile
>>
>> Is it correct that the java code example shown (for specifying the
>> firefox profile to use) is being turned into JsonWireProtocol commands?
>> If so, that is great. But can someone tell me the actual web service
>> commands being used? I can then implement this in the PHP library.
>>
>> (Responses as to why my various attempts to specify the firefox profile
>> failed are also warmly welcome. Here or on StackOverflow, either is fine
>> by me :-)

Simon Stewart

unread,
Sep 9, 2011, 10:51:14 AM9/9/11
to webd...@googlegroups.com
Since the FirefoxDriver will clean up the profile on launch, you only
need to send the bits that are different from an unmodified profile:
this can be pretty small. The extraction is done on the client side.
The java version is here:

http://code.google.com/p/selenium/source/browse/trunk/java/client/src/org/openqa/selenium/firefox/FirefoxProfile.java#480

Basically we decode the base64 and then unzip (yes, it's a zip --- we
always use that when transferring binary data) that binary blob. It's
given the key "firefox_profile" in the Capabilities.

Simon

Stéphane

unread,
Oct 1, 2011, 11:49:26 AM10/1/11
to webdriver
I've just issued a patch to be able to specify a profile name instead
of a profile directory in the capabilities:

http://code.google.com/p/selenium/issues/detail?id=2571

That way you won't need to upload a directory every time.

Stéphane

On 9 sep, 16:51, Simon Stewart <simon.m.stew...@gmail.com> wrote:
> Since the FirefoxDriver will clean up the profile on launch, you only
> need to send the bits that are different from an unmodified profile:
> this can be pretty small. The extraction is done on the client side.
> The java version is here:
>
> http://code.google.com/p/selenium/source/browse/trunk/java/client/src...
> >http://code.google.com/p/selenium/wiki/JsonWireProtocol#Desired_Capab...
>
> >>> I asked a selenium question here:
>
> >>>http://stackoverflow.com/questions/7328494/selenium2-firefox-use-the-...
>
> >>> Is it correct that the java code example shown (for specifying the
> >>> firefox profile to use) is being turned into JsonWireProtocol commands?
> >>> If so, that is great. But can someone tell me the actual web service
> >>> commands being used? I can then implement this in the PHP library.
>
> >>> (Responses as to why my various attempts to specify the firefox profile
> >>> failed are also warmly welcome. Here or on StackOverflow, either is fine
> >>> by me :-)
>
> > --
> > Darren Cook, Software Researcher/Developer
>
> >http://dcook.org/work/(About me and my work)
> >http://dcook.org/blogs.html(My blogs and articles)
Reply all
Reply to author
Forward
0 new messages