3

I'm trying to write automated tests for Hashify Editor. Here are the sorts of assertions I'd like to make:

  1. Assert that a textarea matches a particular selector.

  2. Assert that the textarea is currently empty.

  3. Type "_" into the textarea. Assert that it now contains __, and that the caret is positioned between the two underscores.

  4. Type "hello" into the textarea. Assert that it now contains _hello_, and that the caret is positioned before the second underscore.

  5. Type "_" into the textarea. Assert that it still contains _hello_, and that the caret is now positioned after the second underscore.

I've spent the day playing with Soda and Zombie.js, trying to get this work in either. I've managed to get close with Soda:

soda = require 'soda'

browser = soda.createClient ...

browser
  .chain
  .session()
  .open('/')
  .typeKeys('editor', '_')
  .assertValue('editor', '__')

This assertion success, but the following doesn't:

  .typeKeys('editor', 'hello')
  .assertValue('editor', '_hello_')
  # ERROR: Actual value '__' did not match '_hello_'

Using .type fails in a different manner:

  .type('editor', 'hello')
  .assertValue('editor', '_hello_')
  # ERROR: Actual value 'hello' did not match '_hello_'

The suggestion on #275 of assaf/zombie got my hopes up, but I wasn't able to trigger the textarea's keypress handler using this approach.

Perhaps I'm going about this in the wrong way. Has anyone had success testing keypress handlers using Node? What's the best tool for the job?

davidchambers
  • 23,918
  • 16
  • 76
  • 105
  • If (in soda) first assertion works ok while te second is not (the one with __hello__), maybe there's something wrong with your script? Also, since soda is somehow related to selenium, have you tried to first record and/or run your tests in selenium on regular browser (e.g. on Firefox)? I would go that way since that way you will be able to visually confirm automatic actions conducted by selenium on your browser. – WTK Aug 24 '12 at 13:06

0 Answers0