Skip to content
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

Add sendKeys method #767

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
8 changes: 8 additions & 0 deletions src/Driver/CoreDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ public function setValue($xpath, $value)
throw new UnsupportedDriverActionException('Setting the field value is not supported by %s', $this);
}

/**
* {@inheritdoc}
*/
public function sendKeys($xpath, $value)
{
throw new UnsupportedDriverActionException('Setting the auto-complete field value is not supported by %s', $this);
}

/**
* {@inheritdoc}
*/
Expand Down
13 changes: 13 additions & 0 deletions src/Driver/DriverInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,19 @@ public function getValue($xpath);
*/
public function setValue($xpath, $value);

/**
* Sends keys to an element by it's XPath query.
*
* @param string $xpath
* @param string|bool|array $value
*
* @throws UnsupportedDriverActionException When operation not supported by the driver
* @throws DriverException When the operation cannot be done
*
* @see \Behat\Mink\Element\NodeElement::setAutocompleteValue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure, that mentioned method exists?

*/
public function sendKeys($xpath, $value);

/**
* Checks checkbox by it's XPath query.
*
Expand Down
12 changes: 12 additions & 0 deletions src/Element/NodeElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,18 @@ public function setValue($value)
$this->getDriver()->setValue($this->getXpath(), $value);
}

/**
* Sends keys to an input element
*
* Calling this method on other elements than form fields is not allowed.
*
* @param string|bool|array $value
*/
public function sendKeys($value)
{
$this->getDriver()->sendKeys($this->getXpath(), $value);
}

/**
* Checks whether element has attribute with specified name.
*
Expand Down