Skip to content

Commit 65f5c4a

Browse files
author
Alexandre
committed
Merge pull request alwex#10 from natostanco/patch-1
add send keys method
2 parents 0b1a2af + f1f4571 commit 65f5c4a

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Browser/Casper.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,31 @@ public function fillForm($selector, $data = array(), $submit = false)
181181
this.fill('$selector', $jsonData, $jsonSubmit);
182182
});
183183
184+
FRAGMENT;
185+
186+
$this->_script .= $fragment;
187+
188+
return $this;
189+
}
190+
191+
/**
192+
* Sends native keyboard events
193+
* to the element matching the provided selector:
194+
*
195+
* @param unknown $selector
196+
* @param unknown $string
197+
*
198+
* @return \Browser\Casper
199+
*/
200+
public function sendKeys($selector, $string)
201+
{
202+
$jsonData = json_encode($string);
203+
204+
$fragment =<<<FRAGMENT
205+
casper.then(function () {
206+
this.sendKeys('$selector', $jsonData);
207+
});
208+
184209
FRAGMENT;
185210

186211
$this->_script .= $fragment;

0 commit comments

Comments
 (0)