[QA] Is it possible to send actual keypresses instead of strings?

Chris McMahon cmcmahon at wikimedia.org
Thu Sep 12 13:54:53 UTC 2013


On Wed, Sep 11, 2013 at 9:25 PM, James Forrester
<jforrester at wikimedia.org>wrote:

> I believe Inez (copied) from Wikia who is working on VisualEditor said
> that the Java Selenium driver could do this, but that others generally
> couldn't… but that could be me mis-remembering.
>

Every language that has full support for WebDriver (Java, C#, Python, Ruby)
should support the full range of DOM events:
http://www.w3schools.com/jsref/dom_obj_event.asp

Here is an example of a WIP test for the very latest VisualEditor using
"fire_event(onfocus)", now required to enable the "Save page" button when
doing send_keys to the contentEditable field of the editor:
https://gerrit.wikimedia.org/r/#/c/83817/6/modules/ve-mw/test/browser/features/step_definitions/visual_editor_steps.rb
(line
46)

It is common to need these events from time to time to exercise browsers
properly.  For example, you could explicitly emulate an action with

page.content_element.fire_event('onfocus')
page.content_element.fire_event('onkeydown')
page.content_element.send_keys('H')
page.content_element.fire_event('onkeyup')
page.content_element.fire_event('onkeydown')
page.content_element.send_keys('i')
page.content_element.fire_event('onkeyup')

but in practice you'll rarely need that kind of fine control.

-Chris



>
>
> On 11 September 2013 21:17, Amir E. Aharoni <amir.aharoni at mail.huji.ac.il>wrote:
>
>> If I understand correctly, Selenium's send_keys send strings or
>> characters rather then actual keypresses.
>>
>> Is there a way to send actual keypresses? It's useful for testing
>> different keyboard layouts. See my question on StackOverflow about it:
>> http://stackoverflow.com/questions/18754576/can-i-use-seleniums-send-keys-or-some-other-function-to-send-actual-keys-rather
>> --
>> Amir Elisha Aharoni · אָמִיר אֱלִישָׁע אַהֲרוֹנִי
>> http://aharoni.wordpress.com
>> ‪“We're living in pieces,
>> I want to live in peace.” – T. Moore‬
>>
>> _______________________________________________
>> QA mailing list
>> QA at lists.wikimedia.org
>> https://lists.wikimedia.org/mailman/listinfo/qa
>>
>>
>
>
> --
> James D. Forrester
> Product Manager, VisualEditor
> Wikimedia Foundation, Inc.
>
> jforrester at wikimedia.org | @jdforrester
>
> _______________________________________________
> QA mailing list
> QA at lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/qa
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/qa/attachments/20130912/d3553de6/attachment.html>


More information about the QA mailing list