[QA] how to move the cursor in VisualEditor

Chris McMahon cmcmahon at wikimedia.org
Fri Oct 11 16:00:57 UTC 2013


Among other things, this is a regression test for
https://bugzilla.wikimedia.org/show_bug.cgi?id=54443

We merged this test today:  https://gerrit.wikimedia.org/r/#/c/87620

The interesting part is in the steps file:

When(/^I send right arrow times (\d+)$/) do |number|
  on(VisualEditorPage) do |page|
    page.content_element.when_present.fire_event('onfocus')
    number.to_i.times do
      page.content_element.send_keys :arrow_right
      page.content_element.fire_event('onblur') #gerrit 86800/86801
    end
  end

Before we do anything, we have to fire an 'onfocus' event for the
contentEditable area of VE, in order for the Save page button to become
enabled.

Then every time we send an arrow_right command we also have to send a
corresponding 'onblur' event. (Or at least we do when we move the cursor
onto an "object".)

If the test does not send the onblur event, then upon encountering an
"object" like a reference or a link or a transclusion, the cursor
repositions itself at the beginning of the contentEditable field. It's fun
to watch, but it's not a good test. :-)

If you investigate those 86800/86801 commits in gerrit, you can see how VE
keeps track of where the cursor is.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.wikimedia.org/pipermail/qa/attachments/20131011/40bcdca8/attachment.html>


More information about the QA mailing list