forked from php-webdriver/php-webdriver
-
Notifications
You must be signed in to change notification settings - Fork 0
Launching browsers
Ondřej Machulda edited this page Sep 3, 2016
·
12 revisions
$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
//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:
- Archive the Firefox profile directory into a zip file
- Base 64 encode the zip file and save that output somewhere (can be stored as text file, etc.)
- Read in the base64 encoded data from file into memory and pass that as part of desired capabilities to WebDriver
- 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.
For base64 encoding and zipping up the profile, can use code from here: http://stackoverflow.com/questions/10559728/uploading-files-remotely-on-selenium-webdriver-via-php
References:
http://stackoverflow.com/questions/7328494/selenium2-firefox-use-the-default-profile
http://stackoverflow.com/questions/10559728/uploading-files-remotely-on-selenium-webdriver-via-php
$web_driver = new WebDriver();
$session = $web_driver->session('internet explorer');
//can also pass desired capabilities array like with HTMLUnit
//refer to specific browsers above in terms of desired capabilities as well, but here's an example:
$wd_host = 'http://your-username-string:[email protected]:80/wd/hub';
$web_driver = new WebDriver($wd_host);
$session = $web_driver->session('firefox',array('name' => 'Facebook php-webdriver demo on SauceLabs', 'version' => '3.6'));
//and that's it to connect...