-
Notifications
You must be signed in to change notification settings - Fork 5
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
Why the clearing approach of "setValue" method was changed compared to the Selenium2 driver? #21
Comments
The likely reason is that Some things are clearly related to human behaviour (keyUp, keyDown etc), but others not (get/setCookie, get/setValue etc).
Probably not. |
Browser itself triggers all necessary events |
@oleg-andreyev , I've confirmed, that using @uuf6429 ,
|
@aik099 in order to fire change event, element should lose focus/blur this will happen as soon as you add TAB or switch to different element. https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event
I personally completely against emulating/triggering events on PHP side, they should happen on browser side as "real user" . |
In the end, I don't understand what is the objective of this API since the way Selenium2Driver implements it:
To me it's a bad mixture of both.
That's not a good justification for bad behaviour. Like I said many times in the last several months, I believe that test is wrong. I'd like to see good reasons why it should work like that.
I still don't get why it is "a good thing" when all your 7 points (including point 6) point to it being bad (=> it causes unexpected behaviour, it caused various bugs, it limits functionality).
If those cases are only triggering From my perspective:
With that being said, we should focus on what the facts are and how to improve/fix the situation.
|
@uuf6429 I see it this way: webdriver is low-level client when using it you need to handle everything by yourself (tab, focus, blur and etc), mink drivers are high-level which reduces needs of doing something manual and provides Mink-interface - so if tests (common across all drivers) expects that setValue should trigger change event, then this repository should be compliant with tests. I my initial version https://github.com/oleg-andreyev/MinkPhpWebDriver/blob/aad9b68443e8c93d4a7abcbada4bb1dd2c53f433/src/WebDriver.php#L745 I actually trigger change event. It's not wrong or right per MDN. |
There's no rule to expose the low-level driver. Behat users that must do something that is not available in mink (or that mink messed up) will have to rely on hacks such as exposing/accessing private properties.
That's how I see it too, in theory. In practice, it's actually doing both (setCookie, for example is low level). Unfortunately, there doesn't seem to be any documentation or indication of which parts are low-level and which parts are high-level.
There's only one driver - Selenium2Driver - many driver factories are instantiating that or a javascript-less driver (which means events are skipped). Your driver is based on that one, so it stands to reason that it might have inherited bad behaviour.
That's not saying anything - you just made it pass the test.
MDN is not saying how browsers or humans should behave, it says how browsers are behaving. You can write javascript that sets a field's value without triggering any event, or triggering specific or custom events - it's probably a bad idea, but it's not wrong in itself. The point is, why are we triggering the
Feel free to play around with this: https://jsfiddle.net/ka074hmf/1/
|
The Selenium2 driver was typing Backspace (for Windows) + Delete (for Mac) keys to the input/textarea in the amount needed to erase the current value. That allowed any JavaScript code of that page, that monitored input/textarea value change (e.g., to prevent certain keys from being typed) to behave as if a real human was doing this.
This driver uses the
clear
method of the WebDriver to clear the input/textarea value.Does it fire necessary JS keyboard events in the process as well in every Selenium+Browser combination being tested?
P.S.
clear
WebDriver method might be changing element focus, which might fire a duplicate focus/blur event when usingclear
+sendKeys
together.The text was updated successfully, but these errors were encountered: