lihua
New Member
Posts: 8
|
Post by lihua on Aug 18, 2015 6:02:53 GMT
When I use SeleniumPlus API "Component.InputKeys" on textbox component, I found that it always clicking in the textbox. This will lead to problem when the action of "ctrl + a" is executed in the component. Pelase see below test scenario. 1. In textbox "myTextBox", press "end" key to move cursor after the last character in it: Component.InputKeys(myTextBox, "{End}");
2. Press "Backspace" key to delete the last character in it: Component.InputKeys(myTextBox, "{BackSpace}");
The expected result is the last character in "myTextBox" is deleted, but the actual result is the middle character in "myTextbox" is deleted. Reason: API "Component.InputKeys" always click in the text box to focus and then send key "{BackSpace}".
Resolve: use API "SeleniumPlus.TypeKeys("{BackSpace}");" to replace "Component.InputKeys(myTextBox, "{BackSpace}");".
Please see the attached "problemDescription.png" for this problem.
|
|
|
Post by leiwang on Aug 18, 2015 7:04:04 GMT
This is the side effect to use click to set focus. We have to live with it for some time. For API Component.InputKeys, it is used to input keys into a component, we do need the component having focus before we can input characters or keys to it, but we didn't find a good way to set focus to a web element with selenium's API. We decide to use click to set focus for component of type EditBox. For API SeleniumPlus.TypeKeys, it is used to input keys into a focused component, it will not try to set focus to a component, it is supposed that user has already get the component focused. Your first step Component.InputKeys(myTextBox, "{End}") will set focus to the component "myTextBox", then SeleniumPlus.TypeKeys("{BackSpace}") will just send the "BackSpace" key to the focused component "myTextBox". Here are some other API needs the component having focus already SeleniumPlus.TypeCharsSeleniumPlus.TypeEncryptionHere are some other API will set focus to component before doing actions, they may have the same problem mentioned above Component.InputCharactersAll methods of SeleniumPlus.EditBoxHere is a simple alternative, you can specify multiple keys you want to input like following, try it to see if it works for you. Component.InputKeys(myTextBox, "{End}{BackSpace}");
|
|
lihua
New Member
Posts: 8
|
Post by lihua on Aug 20, 2015 6:05:36 GMT
Hi, Lei,
Thank you very much for the help!
|
|
lihua
New Member
Posts: 8
|
Post by lihua on Aug 20, 2015 7:26:41 GMT
Hi, Lei,
I tried your way and it works fine for me. Thank you very much for providing me the alternate implementation!
|
|
|
Post by leiwang on Aug 20, 2015 8:08:54 GMT
This is not a new implementation , just Component.InputKeys() accepts consecutive keys to input, we input the key {End} and {BackSpace} in one call to avoid the "click to get focus side effect" in implementation of InputKeys.
|
|