expression.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* global normal */
  2. casper.test.begin('Expression', 16, function (test) {
  3. casper
  4. .start('./fixtures/expression.html', function () {
  5. test.assertSelectorHasText('#normal p', 'Hello World!')
  6. test.assertSelectorHasText('#lazy p', 'Hi Ho!')
  7. test.assertField('one', 'Hello')
  8. test.assertField('two', 'World')
  9. test.assertField('three', 'Hi')
  10. test.assertField('four', 'Ho')
  11. // setting value
  12. this.evaluate(function () {
  13. normal.one = 'Hola'
  14. })
  15. test.assertSelectorHasText('#normal p', 'Hola World!')
  16. test.assertField('one', 'Hola')
  17. // setting nested value
  18. this.evaluate(function () {
  19. normal.two.three = 'Casper'
  20. })
  21. test.assertSelectorHasText('#normal p', 'Hola Casper!')
  22. test.assertField('two', 'Casper')
  23. // lazy input
  24. this.fill('#form', {
  25. three: 'three',
  26. four: 'four'
  27. })
  28. test.assertSelectorHasText('#lazy p', 'three four!')
  29. // normal input
  30. this.sendKeys('#one', 'Bye')
  31. test.assertSelectorHasText('#normal p', 'Bye Casper!')
  32. // sd-on with expression
  33. this.click('#normal button')
  34. test.assertField('one', 'clicked')
  35. test.assertSelectorHasText('#normal p', 'clicked Casper!')
  36. // sd-on with expression
  37. this.click('#lazy button')
  38. test.assertField('four', 'clicked')
  39. test.assertSelectorHasText('#lazy p', 'three clicked!')
  40. })
  41. .run(function () {
  42. test.done()
  43. })
  44. })