Skip to content

Example command reference

daluu edited this page Dec 12, 2011 · 30 revisions

Overview

I find the project main page lacking in documenting the API / user interface of this PHP binding for Web Driver. It needs more examples. Perhaps my understanding of the JSONWireProtocol is not in depth enough, but then most Web Driver & Selenium users might not be either just like me. So here is my attempt at helping others learn to use this binding. Others out there who are more experienced with this PHP binding, please add to this page as you get to it please.

Working with elements

NOTE: the examples here are done shorthand, in single line chained calls, though we could save the WebElement into a variable and then make subsequent calls from that element rather from the web driver browser session object. Some of us just prefer concise coding.

Getting text of an element

$result = $session->element('id','signin')->text();

Clicking an element (link, checkbox, etc.)

$session->element('id','signin')->click(""); //POST w/ empty data to click command, as session & element already passed w/ object. Using just click() won't work, I guess POST requires "" where GET can be null.

Typing into text field

Maybe something like this?: $session->element('id','searchText')->value(array("blah")); //didn't work for me. Wrong syntax?

Get attribute of an element

$attr = $session->element('id','signin')->attribute('maxlength');

More commands to come...

Clone this wiki locally