-
Notifications
You must be signed in to change notification settings - Fork 55
Example command reference
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.
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.
$result = $session->element('id','signin')->text();
$session->element('id','signin')->click(""); //POST w/ empty data to click command. using just click() may work for you too.
Values must be sent as an array of key presses.
You could use a function from another webdriver php project (https://github.com/chibimagic/WebDriver-PHP):
function send_keys($toSend){ $payload = array("value" => preg_split("//u", $toSend, -1, PREG_SPLIT_NO_EMPTY)); return $payload; }
This can be used:
$session->element("id", "element id")->value(send_keys("I want to send this"));
Or more simply, it may work to just do:
$session->value(array('value' => str_split("I want to send this")));
$attr = $session->element('id','signin')->attribute('maxlength');