Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can we simulate typing? #59

Open
timwis opened this issue Apr 16, 2018 · 3 comments
Open

How can we simulate typing? #59

timwis opened this issue Apr 16, 2018 · 3 comments

Comments

@timwis
Copy link

timwis commented Apr 16, 2018

I'm really excited about this project. A potential gotcha was pointed out in the hn thread, so I thought I'd take the conversation here since that thread seems to have lost momentum.

How can we simulate typing using remote-browser? Technically we can set an input element's value to something, or create keypress, keydown, etc. events. But it seems that webdriver takes a different approach that's closer to true user input. I don't know how webdriver does it, but the use case is a website that, say, auto-formats a phone number or credit card number as you type it. Sometimes these don't work when you set the value of the input field. Another example is JS-based validations. The type method on puppeteer and selenium seem to fool the browser into thinking a user is typing. How might we achieve this in remote-browser?

@sangaline
Copy link
Member

This is a great question, and it's definitely something that we've been thinking about quite a bit. The philosophy of the project is heavily centered around the idea of things being implemented in vanilla JavaScript using existing browser APIs, so simulating the JavaScript key events is really the closest that we'll be able to get. My understanding is that this should be realistic enough for the vast majority of testing and web scraping tasks, but I would be curious to hear about edge cases where it wouldn't be if you're aware of any.

Simulating key presses like this manually is clearly a bit cumbersome, and our intention isn't that each user should be hacking something like this together themselves. We have some higher-level tooling in the works that will facilitate these sort of interactions, and you can expect an update in the near future that provides similar functionality to that of the type() methods provided by Puppeteer and NightmareJS. This might be implemented as a separate library, but it will be designed to work seamlessly with Remote Browser.

@blueberryman
Copy link

Is there any reason why simulating the full event cycle of a keyboard type shouldn't work?
See a demo taken from here.

@klaussa
Copy link

klaussa commented Aug 1, 2019

By any chance has any update of this topic been released ?

Kind Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants