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

Add sendKeys method #767

wants to merge 6 commits into from

Conversation

JordiGiros
Copy link

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

*/
public function setAutocompleteValue($xpath, $value)
{
throw new UnsupportedDriverActionException('Setting the field value is not supported by %s', $this);
Copy link
Member

Choose a reason for hiding this comment

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

I think, that error message should mention, that value is set into an auto-complete field.

@stof
Copy link
Member

stof commented Oct 18, 2018

I don't think the method name is right. This method should be about typing in a field, not about setting a value IMO. It is not only about autocomplete

@stof
Copy link
Member

stof commented Oct 18, 2018

Note that if we make it a method typing something in the field, we should probably not force emptying first (as that removes control from the user about what gets actually typed in the field)

@stof
Copy link
Member

stof commented Oct 18, 2018

This would make it map to https://www.w3.org/TR/webdriver1/#element-send-keys

@JordiGiros
Copy link
Author

Note that if we make it a method typing something in the field, we should probably not force emptying first (as that removes control from the user about what gets actually typed in the field)

Emptying first as in setValue method? Why not? The behaviour should be nearly the same but without triggering any "change event" and staying the focus in the element. Does this apply here or is a problem we should discus in MinkSelenium2 project?

@JordiGiros
Copy link
Author

JordiGiros commented Oct 18, 2018

I don't think the method name is right. This method should be about typing in a field, not about setting a value IMO. It is not only about autocomplete

Ok, I agree. We can name it "sendKeys()" following W3 naming. But then, in selenium2 driver should we send alls the keys passed to sendKeys() method using keyPress() in loop or we will use postValue()?

In fact in Selenium2Driver->setValue() we already use the method postValue() that basically sends a sequence of key strokes to an element.
We can discuss it here

@stof
Copy link
Member

stof commented Oct 18, 2018

@JordiGiros if you test things for a complex JS widget, you might want to see what happens when writing fr in the field, and then continuing writing to reach fran. If we force to set the value, emptying the field first (which is what minkphp/MinkSelenium2Driver#302 is doing currently), you cannot test that (as your second call would erase everything and then write fran, which is a different usage pattern).
As the intended usage of this method is to be able to test such JS-based UIs, we should make it as usable as possible for that.

@stof
Copy link
Member

stof commented Oct 18, 2018

We also need a method on NodeElement

@stof
Copy link
Member

stof commented Oct 18, 2018

And we need a PR on the driver-testsuite repository with functional tests using this new API, to cover the expected behavior of drivers (otherwise, there is no interoperability between drivers)

@JordiGiros
Copy link
Author

JordiGiros commented Oct 18, 2018

Yes, I see. So not deleting previous string would be a better solution. I'll change that on selenium2driver.

@JordiGiros JordiGiros changed the title Add setAutocompleteValue method Add sendKeys method Nov 5, 2018
@paulbriton
Copy link

Any update on this?

@aik099
Copy link
Member

aik099 commented Apr 17, 2021

#767 (comment)

@JordiGiros , I've specified a place in minkphp/MinkSelenium2Driver#302 that needs to be changed to implement this.

Also I wasn't able to find associated PR in the test suite, that @stof mentioned in #767 (comment) .

* @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?

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.

4 participants