Selenium2 firefox: use the default profile

前端 未结 6 1745
挽巷
挽巷 2020-12-05 12:16

Selenium2, by default, starts firefox with a fresh profile. I like that for a default, but for some good reasons (access to my bookmarks, saved passwords, use my add-ons, et

6条回答
  •  难免孤独
    2020-12-05 12:53

    Simon Stewart answered this on the mailing list for me.

    To summarize his reply: you take your firefox profile, zip it up (zip, not tgz), base64-encode it, then send the whole thing as a /session json request (put the base64 string in the firefox_profile key of the Capabilities object).

    An example way to do this on Linux:

    cd /your/profile
    zip -r profile *
    base64 profile.zip > profile.zip.b64
    

    And then if you're using PHPWebDriver when connecting do:

    $webdriver->connect("firefox", "", array("firefox_profile" => file_get_contents("/your/profile/profile.zip.b64")))
    

    NOTE: It still won't be my real profile, rather a copy of it. So bookmarks won't be remembered, the cache won't be filled, etc.

提交回复
热议问题