-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate keyPress, keyDown, keyUp in favor of pressKey. #831
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #831 +/- ##
============================================
- Coverage 98.47% 97.20% -1.27%
- Complexity 345 353 +8
============================================
Files 23 23
Lines 983 1002 +19
============================================
+ Hits 968 974 +6
- Misses 15 28 +13
Continue to review full report at Codecov.
|
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function keyPress($xpath, $char, $modifier = null) | ||
{ | ||
@trigger_error(sprintf('The method %s is deprecated as of 1.11 and will be removed in 2.0', __METHOD__), E_USER_DEPRECATED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is triggering a deprecation notice from a method, that throws an exception a good idea?
Maybe we should trigger a deprecation notice in driver sub-classes, where this method is completely replaced?
The same goes for other similar places.
* | ||
* @param string|int|array $keys a string to type ('PHP Hypertext Preprocessor'), a integer key code (88), or an array of keys to press in sequence (e.g.: ["\u{E008}", 'H', "\u{E001}", 'ello']). See https://w3c.github.io/webdriver/#keyboard-actions | ||
*/ | ||
public function pressKey($keys) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing an interface is a BC break.
*/ | ||
public function keyPress($char, $modifier = null) | ||
{ | ||
$this->getDriver()->keyPress($this->getXpath(), $char, $modifier); | ||
$this->pressKey($this->wrapCharWithModifier($char, $modifier)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a @deprecated
tag alone in the DocBlock won't help much, but having a matching deprecation notice triggering code will.
The same goes for other similar places in this class.
*/ | ||
public function keyPress($char, $modifier = null) | ||
{ | ||
$this->getDriver()->keyPress($this->getXpath(), $char, $modifier); | ||
$this->pressKey($this->wrapCharWithModifier($char, $modifier)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keyPress
, keyDown
and keyUp
are not something that can be implemented on top of pressKey
, which is the priammy reason to deprecate them.
/** | ||
* Press one or more keyboard keys on an element. | ||
* | ||
* @param string|int|array $keys a string to type ('PHP Hypertext Preprocessor'), a integer key code (88), or an array of keys to press in sequence (e.g.: ["\u{E008}", 'H', "\u{E001}", 'ello']). See https://w3c.github.io/webdriver/#keyboard-actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
our own API should not be based on the Webdriver representation of modifier keys, as that might not fit other drivers.
Problem / motivation
in #828, @stof said that "the [driver methods] that should actually be deprecated are the separate keydown, keypress and keyup methods in favor of a single pressKey method to match what is actually possible in browsers."
Proposed resolution
DriverInterface::keyDown()
,DriverInterface::keyPress()
, andDriverInterface::keyUp()
in favor of a newDriverInterface::pressKey()
NodeElement::keyDown()
,NodeElement::keyPress()
, andNodeElement::keyUp()
in favor of a newNodeElement::pressKey()
Notes
I modelled the
DriverInterface::pressKey()
method after php-webdriver/php-webdriver's\Facebook\WebDriver\Remote\RemoteKeyboard::sendKeys()