Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,26 @@
"homepage": "http://everzet.com"
}
],
"repositories": [
{
"type": "vcs",
"url": "https://github.com/oleg-andreyev/Mink.git",
"no-api": true
},
{
"type": "vcs",
"url": "https://github.com/oleg-andreyev/driver-testsuite.git",
"no-api": true
}
],
"require": {
"php": ">=5.4",
"behat/mink": "~1.7@dev",
"behat/mink": "dev-deprecate-keyup-keypress-keydown",
"instaclick/php-webdriver": "~1.1"
},
"require-dev": {
"mink/driver-testsuite": "dev-master"
"mink/driver-testsuite": "dev-mink-772"
},

"autoload": {
"psr-4": {
"Behat\\Mink\\Driver\\": "src/"
Expand Down
43 changes: 43 additions & 0 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,49 @@ public function keyUp($xpath, $char, $modifier = null)
$this->trigger($xpath, 'keyup', $options);
}

/**
* {@inheritdoc}
*/
public function pressKey($xpath, $char, $modifier = null)
{
$keys = array();

$modifier = $this->keyModifier($modifier);
if ($modifier) {
$keys[] = $modifier;
}

$keys[] = $char;

if ($modifier) {
$keys[] = Key::NULL_KEY;
}

$this->findElement($xpath)->postValue(array('value' => array_map('strval', $keys)));
}

/**
* Converts alt/ctrl/shift/meta to corresponded Key::* constant
*
* @param string $modifier
*
* @return string
*/
private function keyModifier($modifier)
{
if ($modifier === 'alt') {
$modifier = Key::ALT;
} else if ($modifier === 'ctrl') {
$modifier = Key::CONTROL;
} else if ($modifier === 'shift') {
$modifier = Key::SHIFT;
} else if ($modifier === 'meta') {
$modifier = Key::META;
}

return $modifier;
}

/**
* {@inheritdoc}
*/
Expand Down