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

Basic input #45

Merged
merged 5 commits into from
Jun 28, 2017
Merged

Basic input #45

merged 5 commits into from
Jun 28, 2017

Conversation

JoelEinbinder
Copy link
Collaborator

#43
Adds

.click(selector)
.focus(selector)
.type(text)

<!DOCTYPE html>
<html>
<head>
<title>Button test</title>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

text area test?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

lib/Page.js Outdated
* @param {!Promise<number>}
*/
async _querySelector(selector) {
let documentNode = await this._client.send('DOM.getDocument', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should query for the document only once in the very beginning

lib/Page.js Outdated
let boxModel = (await this._client.send('DOM.getBoxModel', {
nodeId: await this._querySelector(selector)
})).model.content;
let x = Math.round((boxModel[0] + boxModel[0]) / 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels like an error

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

lib/Page.js Outdated
let x = Math.round((boxModel[0] + boxModel[0]) / 2);
let y = Math.round((boxModel[1] + boxModel[1]) / 2);

await this._client.send('Input.dispatchMouseEvent', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can await only the last one due to the serial nature of the protocol

lib/Page.js Outdated
* @param {!Promise}
*/
async focus(selector) {
await this.evaluate(selector => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's use DOM.querySelector and DOM.focus

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/Page.js Outdated
for (let i = 0; i < text.length; i++) {
let code = text.charCodeAt(i);
let char = text.charAt(i);
await this._client.send('Input.dispatchKeyEvent', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you'd probably speed this up considerably if you were to wait only for the very last one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<body>
<textarea></textarea>
<script>
window.result = "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

''

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@aslushnikov aslushnikov merged commit d5a9165 into puppeteer:master Jun 28, 2017
@JoelEinbinder JoelEinbinder deleted the core_input branch August 2, 2017 23:09
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

Successfully merging this pull request may close these issues.

None yet

2 participants