Skip to content

Launching browsers

daluu edited this page Dec 29, 2011 · 9 revisions

Launching Different Browsers

$web_driver = new WebDriver();
$session = $web_driver->session('htmlunit', array('javascriptEnabled' => true, 'version' => '3.6'));
$web_driver = new WebDriver();
$session = $web_driver->session('firefox');
//can also pass desired capabilities array like with HTMLUnit

Adding a Firefox Profile

//see notes below for full details
$web_driver = new WebDriver();
$session = $web_driver->session('firefox', array('firefox_profile' => file_get_contents("pathTo\Base64EncodedZipFileOfFirefoxProfile.txt")));
//can also pass additional desired capabilities above

You can specify a Firefox profile by doing the following steps:

  1. Archive the Firefox profile directory into a zip file
  2. Base 64 encode the zip file and save that output somewhere (can be stored as text file, etc.)
  3. Read in the base64 encoded data from file into memory and pass that as part of desired capabilities to WebDriver
  4. Someone else or myself can later update this wiki to provide optimal PHP code to do steps 1-2. Step 3 covered already.

Profile does not need to exist at target machine, as we basically upload profile from client to the server to use.

References:

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

http://groups.google.com/group/webdriver/browse_thread/thread/ebde7fe7986e1f6e/865a7f4c864b6630?lnk=gst&q=profile+jsonwire#865a7f4c864b6630

http://groups.google.com/group/webdriver/browse_thread/thread/ebde7fe7986e1f6e/865a7f4c864b6630?lnk=gst&q=David#865a7f4c864b6630

$web_driver = new WebDriver();
$session = $web_driver->session('internet explorer');
//can also pass desired capabilities array like with HTMLUnit