I think both org.openqa.selenium.htmlunit.HtmlUnitWebElement.sendKeys(CharSequence...) and com.gargoylesoftware.htmlunit.html.HtmlElement.type(char, boolean, boolean, boolean) need to be modified
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But why does the user have to know that '\n' is special character? Keyboard itself could handle the transformation from .type(char) to .press(int) and .release(int).
Also I would expect the HtmlUnit to submit the form, if the event is not prevented.
Fixing the com.gargoylesoftware.htmlunit.html.HtmlElement.type(char, boolean, boolean, boolean) seems like correct way to me.
Previously, it was type(char), and then type(int) was added for special keys. Then came cases where you need to press(shift), type('a'), release(shift), so special characters (alt,shift,ctrl) shouldn't be typed (as the wouldn't make much use in this case), but pressed/released before/after other characters.
For '\n' I can see you point.
Please feel free to submit your recommendations.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Failing testcase
Last edit: Madis Pärn 2016-04-11
I think both org.openqa.selenium.htmlunit.HtmlUnitWebElement.sendKeys(CharSequence...) and com.gargoylesoftware.htmlunit.html.HtmlElement.type(char, boolean, boolean, boolean) need to be modified
This is related to HtmlUnitDriver, which should use the type(Keyboard) instead of sending the characters.
The below scenario succeess with direct usage of HtmlUnit.
Do you suggest I should be using the HtmlElement.type(int) instead of HtmlElement.type(String) ?
If you can directly use HtmlUnit (without HtmlUnitDriver), then go ahead and use the type(int).
On the long term, all should be replaced by type(Keyboard).
When using HtmlElement.type(Keyboard) I also get the unexpected form submittal.
Also some kind of KeyboardBuilder would be nice
Last edit: Madis Pärn 2016-04-12
Keyboard should prevent using special 'characters' as '\n'. Please use .press(int) and .release(int).
Feel free to sumbmit patch for KeybaordBuilder :)
Keyboard as builder patch
But why does the user have to know that '\n' is special character? Keyboard itself could handle the transformation from
.type(char)to.press(int)and.release(int).Also I would expect the HtmlUnit to submit the form, if the event is not prevented.
Fixing the
com.gargoylesoftware.htmlunit.html.HtmlElement.type(char, boolean, boolean, boolean)seems like correct way to me.Last edit: Madis Pärn 2016-04-12
I just want to hint about few things.
Previously, it was type(char), and then type(int) was added for special keys. Then came cases where you need to press(shift), type('a'), release(shift), so special characters (alt,shift,ctrl) shouldn't be typed (as the wouldn't make much use in this case), but pressed/released before/after other characters.
For '\n' I can see you point.
Please feel free to submit your recommendations.
I have no other suggestions, besides the already attached batch HtmlElement.java.patch