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 implementing Mink DriverInterface #302

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Add sendKeys method implementing Mink DriverInterface #302

wants to merge 7 commits into from

Conversation

JordiGiros
Copy link

@JordiGiros JordiGiros commented Oct 18, 2018

Implemented method "sendKeys" in order to solve setting a value on autocomplete input elements as commented in 286, 292 and 301

Related to 767 PR open in Mink project.

src/Selenium2Driver.php Show resolved Hide resolved
$element = $this->findElement($xpath);
$elementName = strtolower($element->name());

if ('select' === $elementName) {
Copy link
Member

Choose a reason for hiding this comment

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

Why this IF is needed. Instead I'm proposing to allow only these elements in method:

  • input HTML elements with specific type attribute values (already done)
  • maybe textarea elements

Copy link
Author

Choose a reason for hiding this comment

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

So, do we want to accept selects?
If we only leave in the method the "input" IF, textarea input types will be accepted by default.

@JordiGiros JordiGiros changed the title Add setAutocompleteValue implementing Mink DriverInterface Add sendKeys method implementing Mink DriverInterface Nov 5, 2018
Comment on lines +1233 to +1236
if (in_array($elementName, array('input', 'textarea'))) {
$existingValueLength = strlen($element->attribute('value'));
$value = str_repeat(Key::BACKSPACE . Key::DELETE, $existingValueLength) . $value;
}
Copy link
Member

Choose a reason for hiding this comment

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

If I understood @stof comment (see minkphp/Mink#767 (comment)) correctly, then this should be moved back to setValue method to allow sendKeys to send keys (as the name suggests) instead of replacing current input value with provided one (as the setValue method does).

edosenseidotcom added a commit to edosenseidotcom/MinkSelenium2Driver that referenced this pull request Jun 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants