diff --git a/composer.json b/composer.json index f130a130..f5f6338f 100644 --- a/composer.json +++ b/composer.json @@ -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/" diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index 0f99a9e6..89610d59 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -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} */