PHP Unit Selenium Webdriver: How to send key by keystroke with sendKeys()
I'm using the facebook webdriver with PHP Unit
Due to some filtering issues in a table I want to be able to sendKeys but key by key. Let's say I click on the field and I want to enter ' Selenium '
$this->webDriver->findElement(WebDriverBy::id('Sessies'))->click();
$this->webDriver->getKeyboard()->sendKeys('Selenium');
This would just paste ' Selenium ' in the field but I want it to type: S
then e
then l
and so on.
Is there anyway that I can do this besides:
$this->webDriver->getKeyboard()->sendKeys('S');
$this->webDriver->getKeyboard()->sendKeys('e');
$this->webDriver->getKeyboard()->sendKeys('l');
// and so on ...
EDIT: Trying out andrey's option below:
$var = 'Selenium';
for ($i = 0; $i<strlen($var); $i++) {
$character = substr($var, $i,1);
$this->webDriver->getKeyboard()->sendKeys($character);
}
Result = it sends the key ' m ' but that's all.
Only split word on letters and iterate over each of it. I don't know php but thinks this will look like:
//$var it's your word
for ($i = 0; $i<strlen($var); $i++) {
$character = substr($var, $i,1);
$this->webDriver->getKeyboard()->sendKeys($character);
}
链接地址: http://www.djcxy.com/p/58140.html