Mink icon indicating copy to clipboard operation
Mink copied to clipboard

Add sendKeys method

Open JordiGiros opened this issue 6 years ago • 11 comments

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

JordiGiros avatar Oct 18 '18 10:10 JordiGiros

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 avatar Oct 18 '18 12:10 stof

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 avatar Oct 18 '18 12:10 stof

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

stof avatar Oct 18 '18 12:10 stof

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 avatar Oct 18 '18 13:10 JordiGiros

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

JordiGiros avatar Oct 18 '18 13:10 JordiGiros

@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 https://github.com/minkphp/MinkSelenium2Driver/pull/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 avatar Oct 18 '18 13:10 stof

We also need a method on NodeElement

stof avatar Oct 18 '18 14:10 stof

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)

stof avatar Oct 18 '18 14:10 stof

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

JordiGiros avatar Oct 18 '18 14:10 JordiGiros

Any update on this?

paulbriton avatar Apr 16 '21 08:04 paulbriton

https://github.com/minkphp/Mink/pull/767#issuecomment-431032401

@JordiGiros , I've specified a place in https://github.com/minkphp/MinkSelenium2Driver/pull/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 https://github.com/minkphp/Mink/pull/767#issuecomment-431020462 .

aik099 avatar Apr 17 '21 12:04 aik099