phantombuster / nickjs

Web scraping library made by the Phantombuster team. Modern, simple & works on all websites. (Deprecated)
https://nickjs.org
ISC License
501 stars 48 forks source link

Simulate a Enter event #30

Closed jprrabanal closed 6 years ago

jprrabanal commented 6 years ago

How do i simulate a Enter event, like pressing enter after sending keys in a textarea?

paps commented 6 years ago

Funny you're asking this now, we just discussed this last week with the team.

It turns out that putting \r in your sendKeys() string will send an Enter key press.

jprrabanal commented 6 years ago

about the sendKeys() are keys send as a whole? I mean just like copying and pasting to a textfield

paps commented 6 years ago

Behind the scenes it's calling the DevTools dispatchKeyEvent (https://chromedevtools.github.io/devtools-protocol/tot/Input#method-dispatchKeyEvent) which is, I think, sending real key presses. Not 100% sure though.