-
Notifications
You must be signed in to change notification settings - Fork 62
Example command reference
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: some examples below may be done shorthand, in single line chained calls from the session object, though if we wanted to perform several actions on the same element, we could save the WebDriverElement into a variable and then make subsequent calls from that element.
$result = $session->element('id','signin')->text();
//POST w/ empty data to click command. using just click() may work for you too.
$session->element('id','signin')->click("");
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 split_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(split_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")));
Or you can try setting the text inputs value directly via javascript like this:
$script = 'arguments[0].value = arguments[1];';
$args = array(array('ELEMENT' => $this->getID()), "I want to send this")));
$session->execute(array('script' => $script, 'args' => $args));
$attr = $session->element('id','signin')->attribute('maxlength');
$element->attribute("value"); //no direct method to call like $element->value();