CasperJS: swallows special keys like Enter?

送分小仙女□ 提交于 2019-11-28 22:03:24

You might want to add {keepFocus: true} to the first sendKeys call. If you see the source code, without adding a keepFocus, it is blurring the text area and that means your second sendKeys call will not accept the keypress.

This seems to work.

casper.start('http://localhost:3000/input-demo', function() {
  this.sendKeys('#demo-input', 'demo text', {keepFocus: true});
  this.sendKeys('#demo-input', casper.page.event.key.Enter , {keepFocus: true});
  this.test.assertEquals(this.getHTML('#stage'), 'input demo');
});

casper.run();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!