php-webdriver -- A very thin wrapper of WebDriver
This client aims to be as thin as possible, abusing the dynamic nature of PHP to allow almost all API calls to be a direct transformation of what is defined in the WebDriver protocol itself.
Most clients require you to first read the protocol to see what's possible, then study the client itself to see how to call it. This hopes to eliminate the latter step, and invites you to rely almost exclusively on http://code.google.com/p/selenium/wiki/JsonWireProtocol
Each command is just the name of a function call, and each additional path is just another chained function call. The function parameter is then either an array() if the command takes JSON parameters, or an individual primitive if it takes a URL parameter.
Note that all of these match the Protocol exactly
Get a session (opens a new browser window)
$web_driver = new WebDriver(); // could pass a host besides localhost
$session = $web_driver->session(); // could pass a browser name
Move to a specific spot on the screen
$session->moveto(array('xoffset' => 3, 'yoffset' => 300));
Change asynchronous script timeout
$session->timeouts()->async_script(array('ms' => 2000));
Check if two elements are equal
Get value of css property on element
'GET', 'POST', or 'DELETE' to the same command examples
If you can do multiple http methods for the same command, such as 'orientation', where 'POST' changes the orientation but 'GET' fetches it, call the command directly for the getter, and prepend the http method for the writers.
Set landscape orientation
$session->postOrientation(array('orientation' => 'LANDSCAPE'));
Get landscape orientation
A few Element/Cookie/Session convenience exceptions.
- Use element($using, $value) and elements($using, $value)
- Use getAllCookies(), setCookie($cookie_json), deleteAllCookies(), and deleteCookie($name)
- Visit pages with open(), close the browser window with close()