4

I am trying to automate some things only with phantomjs. Doing the same work with casperjs works but the challenge is to get it working only with phantomjs. I want to press enter in a normal textfield which I have focused on.

page.sendEvent('keypress', page.event.key.A); //this works
page.sendEvent('keypress', page.event.key.Enter); //this doesn't work

The script runs without any errors but in the output I can see that the enter event did not work.

I tested another function which worked:

page.sendEvent('keypress', page.event.key.A); //this works
page.sendEvent('keypress', page.event.key.Backspace); //this works

Why is only the enter event not working? Every other key works. Is there a way to do it with keycodes?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Steven
  • 135
  • 2
  • 11
  • 1
    This may have something to do with the page you're automating/testing. I tried on SO and it is the other way around: https://gist.github.com/artjomb/87ec080f37b609fee288 – Artjom B. Oct 31 '14 at 08:40
  • have you tried page.event.key.Return? – JawzX Apr 18 '16 at 15:00

0 Answers0