validation.js 664 B

1234567891011121314151617181920212223242526
  1. casper.test.begin('Validation', 4, function (test) {
  2. casper
  3. .start('./fixtures/validation.html')
  4. .then(function () {
  5. test.assertElementCount('.valid', 0)
  6. this.sendKeys('input', '@hello.com')
  7. })
  8. .then(function () {
  9. test.assertElementCount('.valid', 1)
  10. })
  11. .thenEvaluate(function () {
  12. document.querySelector('input').setSelectionRange(4,4)
  13. })
  14. .then(function () {
  15. this.sendKeys('input', 'hoho')
  16. })
  17. .then(function () {
  18. test.assertElementCount('.valid', 1)
  19. test.assertField('email', 'hihihoho@hello.com')
  20. })
  21. .run(function () {
  22. test.done()
  23. })
  24. })