Commit Graph

235 Commits

Author SHA1 Message Date
Andrey Lushnikov
e6af6e19d6 feat(console): dispatch JSHandles as console arguments (#975)
This patch starts dispatching JSHandle instances as console arguments.

BREAKING CHANGE: this changes the API of the ConsoleMessage.

Fixes #324.
2017-10-09 17:01:01 -07:00
JoelEinbinder
8d1d9fec65 chore(doc): replace 'could' with 'can' 2017-10-09 13:28:48 -07:00
JoelEinbinder
a7672acb85 fix: return undefined when Page.evaluate encounters circular JSON (#983) 2017-10-09 12:30:05 -07:00
Vse Mozhet Byt
44cdf85b77 chore(doc): fix a link (#977) 2017-10-07 08:32:40 -07:00
Vse Mozhet Byt
4e558674a8 chore(doc): fix nits after JSHandles PR (#976) 2017-10-07 08:31:55 -07:00
Andrey Lushnikov
3214bb73b0 chore(doc): fix implicit link to JSHandle 2017-10-07 00:34:54 -07:00
JoelEinbinder
0af0d7dba5 feat(Input): Add keyboard methods to elementHandle (#801)
This patch:
- adds input methods to ElementHandle, such as ElementHandle.type and ElementHandle.press
- changes `page.type` to accept selector as the first argument
- removes `page.press` method. The `page.press` is rarely used and doesn't operate with selectors; if there's a need to press a button, `page.keyboard.press` should be used.

BREAKING CHANGE: `page.type` is changed, `page.press` is removed.

Fixes #241.
2017-10-07 00:28:24 -07:00
Andrey Lushnikov
0d0f9b7984 feat(JSHandles): introduce JSHandles (#943)
This patch:
- introduces ExecutionContext class that incapsulates javascript
  execution context. An examples of execution contexts are workers and
  frames
- introduces JSHandle that holds a references to the javascript
  object in ExecutionContext
- inherits ElementHandle from JSHandle

Fixes #382.
2017-10-06 15:35:02 -07:00
Andrey Lushnikov
59bcc2ee56 chore(docs): fix console example in docs/api.md 2017-10-05 17:34:13 -07:00
Benoît Zugmeyer
c225b93037 feat(Launcher): Allow environment variables definition when launching chromium (#912)
This patch adds `env` option to the `puppeteer.launch` method to define custom environment
variables to the launched chrome.
2017-10-05 14:34:35 -07:00
Sam Verschueren
97e40e6823 feat(Frame): Add addStyleTag API to frame - fixes #892 (#947)
This patch adds `Page.addStyleTag` and `Frame.addStyleTag` methods to the API.

Fixes #892.
2017-10-04 13:42:26 -07:00
Vse Mozhet Byt
f9640a5498 chore(doc): add a note about using ElementHandle instances (#925) 2017-10-01 15:47:40 -07:00
Adi Prasetyo
53531c9a92 feat(page): Allow Page.goto's timeout to be 0 to disable timeout (#887)
This patch allows passing 0 to disable timeout for the following methods:

- page.goto
- page.waitForNavigation
- page.goForward
- page.goBack

Fixes #782.
2017-09-30 00:29:38 -07:00
Vse Mozhet Byt
1c292e9253 chore(doc): fix browser.wsEndpoint() return value format (#898) 2017-09-29 14:59:19 -07:00
Andrey Lushnikov
f6255029bd feat(Console): Introduce ConsoleMessage type (#909)
This patch introduces ConsoleMessage type and starts dispatching
it for the 'console' event.

BREAKING CHANGE: this breaks the api of the 'console' event.

Fixes #744.
2017-09-29 11:27:22 -07:00
Jake Ginnivan
0164b7cc4e Added info on how to find the browserWSEndpoint (#780) 2017-09-26 07:04:09 -07:00
Andrey Lushnikov
9b0a06216e [docs] clarify env variables usage with npmrc 2017-09-26 11:15:18 +09:00
gordomium
2babcb0021 [feat] Support PUPPETEER_SKIP_CHROMIUM_DOWNLOAD in npmrc
This patch adds support for PUPPETEER_SKIP_CHROMIUM_DOWNLOAD
variable in npm config.

This aligns the variable with the rest of supported environment variables.
2017-09-26 11:10:46 +09:00
Alix Axel
45f264024b [api] Introduce Page.select method (#779)
This patch adds `Page.select` method to select
values in a `select` tag.
2017-09-25 18:23:34 +09:00
Vse Mozhet Byt
acdb588964 doc: fix a link (#856) 2017-09-22 16:16:52 -07:00
Andrey Lushnikov
bc4aefaf9f Bump version to 0.12.0-alpha 2017-09-21 15:08:39 +09:00
Andrey Lushnikov
433b17b5d2 Mark version 0.11.0 2017-09-21 14:43:21 +09:00
Vse Mozhet Byt
715296443c Document headless mode restriction for PDF (#836)
Fixes: https://github.com/GoogleChrome/puppeteer/issues/830
2017-09-20 16:51:25 -07:00
cohesively
aa58f25bc1 doc: add await to browser.close in usage examples (#797)
browser.close returns a promise after f398e69, so it should be awaited.
2017-09-15 21:27:14 -07:00
JoelEinbinder
e2cad568d6 page.waitFor should send ...args to page.waitForFunction (#775)
This lets the user pass `...args` into `page.waitFor`. It also clarifies that the docs that `options` is not optional if `...args` are specified.

Fixes #770
2017-09-15 14:28:15 -07:00
Andrey Lushnikov
d562db3140 Assert that all extra HTTP header values are strings (#781)
Since protocol ignores all HTTP headers that don't have string
value, this patch starts validating header key-values before
sending them over the protocol.

Fixes #713.
2017-09-14 19:08:48 -07:00
Adi Prasetyo
a20df0df62 [Doc] add link to environment variable wiki page (#792) 2017-09-14 11:44:18 -07:00
JoelEinbinder
f398e69dbb [api] Launcher: Close gracefully when a userDataDir is specified (#700)
This patch:
- makes `browser.close()` return a promise that resolves when browser gets closed
- starts closing chrome gracefully if a custom `userDataDir` is supplied

Fixes #527
2017-09-13 21:27:14 -07:00
Andrey Lushnikov
d7e673645a [api] add Puppeteer.executablePath() method (#771)
This patch adds Puppeteer.executablePath() method to query the path
of bundled chromium.

Fixes #745
2017-09-13 17:39:18 -07:00
Andrey Lushnikov
9292a56eaf [api] Teach page.evaluate to accept element handles as parameters (#725)
This patch:
- teaches `page.evaluate` to accept ElementHandles as parameters
- removes `ElementHandle.evaluate` method since it's not needed any
  more

References #382
2017-09-11 19:20:02 -07:00
Andrey Lushnikov
0db6165d73 [api] Implement page.authenticate method (#729)
This patch implements `page.authenticate` which should cover all
cases of HTTP authentication.

Fixes #426.
2017-09-11 16:32:13 -07:00
Andrey Lushnikov
0bea42bd8c Do not leave dangling promises when sending messages over protocol (#742)
It's very bad to have 'unhandled promise rejection' that can't be
handled in user code. These errors will exit node process in a near
future.

This patch avoids 'unhandled promise rejection' while sending protocol
messages.

This patch:
- introduces `puppeteer:error` debug scope and starts using it for all
  swalloed errors.
- makes sure that every `client.send` method is either awaited or its
  errors are handled.
- starts return promises from Request.continue() and Request.abort().
- starts swallow errors from Request.contine() and Request.abort().

The last is the most important part of the patch. Since
`Request.continue()` might try to continue canceled request, we should
disregard the error.

Fixes #627.
2017-09-11 16:21:51 -07:00
Andrey Lushnikov
113bdafbf0 Bump version to 0.11.0-alpha 2017-09-08 13:37:47 -07:00
Andrey Lushnikov
2817130fe0 Mark version 0.10.2 2017-09-01 21:02:08 -07:00
JoelEinbinder
64124df62f [api] add touchScreen.tap (#639)
This patch:
- adds `page.touchscreen` namespace, similar to `page.mouse` and `page.keyboard`.
- adds tapping to multiple layers:
  - `page.touchscreen.tap`
  - `page.tap` - convenience method which accepts selector
  - `elementHandle.tap`

Fixes #568 and #569.
2017-09-01 19:03:51 -07:00
Andrey Lushnikov
62ececb1c7 Implement page.$eval (#638)
This patch:
- implements page.$eval and frame.$eval
- drops elementHandle.attribute() method in favor of the page.$eval

References #625
2017-08-31 15:38:01 -07:00
Lucas Hill
ce01e84381 [doc] Clarify networkIdleInflight default in docs. (#630) 2017-08-30 23:08:46 -07:00
Andrey Lushnikov
9d7929cd36 Add environment variable to skip download (#606)
This patch:
- starts skipping chromium download if `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` env variable is set
- adds description of support env variables to the `docs/api.md`.

References #603
2017-08-30 21:40:15 -07:00
Andrey Lushnikov
11ce8b249f Implement Request.resourceType getter (#590)
This patch plumbs `resourceType` parameter of RequestWillBeSent
and requestIntercepted methods.
2017-08-29 16:27:59 -07:00
JoelEinbinder
8f74cc8a90 [api] Add "step" option to mouse.move method (#601)
This patch adds "step" option to the mouse.move method, that optionally tweens mouse movement over multiple steps.

References #423.
2017-08-29 14:13:38 -07:00
Batiste Bieler
77600c6c5e Implement ElementHandle.attribute() method (#543)
This patch implements ElementHandle.attribute() method to fetch a value of
element's attribute.
2017-08-29 11:24:32 -07:00
JoelEinbinder
d5327e6a0f [api] Allow a custom userDataDir to be specified (#555)
This patch adds a `userDataDir` option to the `puppeteer.launch()` method.

Fixes #411.
2017-08-28 12:14:20 -07:00
Andrey Lushnikov
66912a7277 [api] use object instead of map for headers (#567)
This patch:

- switches to objects instead of maps for headers (in Request, Response and
page.setExtraHTTPHeaders)
- converts all header names to lower case

Fixes #547, fixes #509
2017-08-28 12:09:24 -07:00
Andrey Lushnikov
39b9081747 Bump version to 0.10.2-alpha (#566) 2017-08-28 11:15:11 -07:00
Lukasz Szóstek
59fc757ee0 [docs] a mistake in allowed values of page.evaluateMedia (#580) 2017-08-28 10:37:38 -07:00
Eric Bidelman
f9abc8ea03 readme: move up note about Page.pdf working on headless only (#577)
Hard to find. From https://github.com/GoogleChrome/puppeteer/issues/576
2017-08-28 10:31:35 -07:00
Andrey Lushnikov
ea4f8d78fc Mark version 0.10.1 2017-08-25 19:37:53 -07:00
Andrey Lushnikov
be4da580d4 Bump tip-of-tree version to 0.10.1-alpha (#534)
This patch:
- bumps tip-of-tree version to 0.10.1-alpha
- updates api.md to refer to released API and fix a nit in README.md
2017-08-24 22:47:57 -07:00
Andrey Lushnikov
751164c69f Mark version 0.10.0 2017-08-24 18:11:43 -07:00
JoelEinbinder
0791774faa Cookies (#314)
Introduce cookies API. 

Fixes #53.
2017-08-24 12:21:46 -07:00
Andrey Lushnikov
b8c3686e6d [doc] elaborate on url parameter in page.goto. (#504) 2017-08-23 15:34:57 -07:00
Vse Mozhet Byt
4471969524 fix a typo in the api.md (#505) 2017-08-23 14:29:47 -07:00
JoelEinbinder
a1414de42f Implement page.setJavaScriptEnabled method
Fixes #462.
2017-08-23 14:08:56 -07:00
Andrey Lushnikov
63e2b36d29 [doc] Add reference to released API 2017-08-23 13:44:44 -07:00
Eric Bidelman
a330c8eeba Bump version to 0.9.1-alpha
This patch bumps version to 0.9.1-alpha.
This should emphasize that the documentation is related to the tip-of-tree
version of puppeteer, not to the latest release.
2017-08-23 13:39:35 -07:00
Andrey Lushnikov
151d512ae2 Implement page.$$ method (#463)
This patch implements page.$$ which runs document.querySelectorAll
in page and returns results as an array of ElementHandle instances.

Fixes #384.
2017-08-22 22:56:55 -07:00
Andrey Lushnikov
271fd09379 Launcher: add timeout to chrome launching (#434)
This patch:
- adds a 'timeout' launcher option that constrains the time for chromium to launch.
- adds a 'handleSIGINT' launcher option that is `true` by default and that closes chrome instance

Fixes #363.
2017-08-21 15:43:36 -07:00
John Resig
598f439a32 Add Page.content() method. Fixes #406. (#419) 2017-08-21 09:02:30 -07:00
R.Frega
16e1499dbe doc: fix typo (#431) 2017-08-20 19:54:05 -07:00
Vse Mozhet Byt
281db8fecc doc: change ambiguous phrase in api.md (#410) 2017-08-20 16:44:52 -07:00
Andrey Lushnikov
292c7a237f doc: remove mentions of removed Boxy mixin (#425)
Fixes #399.
2017-08-20 16:03:30 -07:00
Andrey Lushnikov
6a35c97c7f doc: fix descriptions of certain page methods (#424)
This patch fixes descriptions of:
- page.click()
- page.focus()
- page.hover()

Fixes #397
2017-08-20 16:03:14 -07:00
Vse Mozhet Byt
6581416897 doc: fix some nits in code examples from api.md (#407)
* Replace let with const in examples when appropriate.
* Unify spacing.
* Fix possible copy-paste artifacts.
* Eliminate one unhandled promise rejection ('Target closed').
2017-08-20 14:50:24 -07:00
Vse Mozhet Byt
9ede3144c5 doc: fix some links in api.md (#400) 2017-08-20 14:32:53 -07:00
Andrey Lushnikov
ab125f6a69 doc: Fix return type in response.text() 2017-08-20 14:32:14 -07:00
Vse Mozhet Byt
970e9c4b35 doc: fix copy-paste artefacts (#394) 2017-08-19 10:04:02 -07:00
Vse Mozhet Byt
f8515013ab doc: remove a link to a deleted example (#392)
Refs: https://github.com/GoogleChrome/puppeteer/pull/221
2017-08-19 09:28:58 -07:00
Andrey Lushnikov
6cc274135c Introduce page.emulateMedia method (#383)
Emulating `screen` media would force `page.pdf()` to print with `screen`
media.

Fixes #312
2017-08-18 16:49:02 -07:00
Brikou CARRE
8f43befcc9 Make prettier JS snippets (#377)
* Make prettier JS snippets

* Conform to CS (about curly brace)

* Apply feedback
2017-08-18 16:46:10 -07:00
Pavel Feldman
127f3966d7 Allow capturing transparent screenshots (#354)
This patch adds `omitBackground` option to the `page.screenshot` method.

Fixes #344
2017-08-17 21:11:39 -07:00
JoelEinbinder
b9c7c367ef Add Serializable type into the docs (#318) 2017-08-17 20:24:11 -07:00
JoelEinbinder
5f0afd5547 Move uploadFiles onto ElementHandle (#348)
This patch:
- removes the `page.uploadFile` method
- adds `elementHandle.uploadFile` method.

Motivation: `elementHandle.uploadFile` is rarely used, so it doesn't worth it
to keep it on page.
2017-08-17 14:53:37 -07:00
Simone Sanfratello
2655f20fd3 docs: fix link to ElementHandle (#345) 2017-08-17 09:26:10 -07:00
Satoshi Takeda
e7356bf611 docs: fix typo in event: 'load' section (#325)
fix `JavaScriot` to `JavaScript`
2017-08-16 23:27:19 -07:00
Chandan Rai
e5876c7b4e corrected minor typos (#322) 2017-08-16 21:57:23 -07:00
edgar c
3cc5ba4a6f update code example: setRequestInterceptionEnabled (#294) 2017-08-16 11:19:13 -07:00
Jonathan Garbee
da53218107 Fix doc on pdf method. Minor addition to PDF path option docs. (#292) 2017-08-16 11:11:40 -07:00
Paul Irish
92e64e2354 docs: recommendation of canary if Chrome is preferred (#293) 2017-08-16 11:09:18 -07:00
Andrey Lushnikov
0a190ebec9 Rename 'remoteDebuggingURL' into 'browserWSEndpoint' (#272) 2017-08-16 01:10:55 -07:00
Andrey Lushnikov
44c15220f9 Rename ElementHandle.release into ElementHandle.dispose (#284)
The ElementHandle.release feels related to ElementHandle.click.
The dispose is a more clear name.
2017-08-16 00:49:20 -07:00
JoelEinbinder
3c2aaaaeb0 Readme fixup part 1 (#278) 2017-08-15 23:04:16 -07:00
Andrey Lushnikov
1e5d9fd8c0 Proofreading documentation (#274)
This patch fixes documentation in a few places.
2017-08-15 17:33:03 -07:00
Andrey Lushnikov
af89e893e7 Implement basic element handles (#248)
This patch implements basic element handles which a backed with remote objects.

Fixes #111
2017-08-15 14:54:02 -07:00
Andrey Lushnikov
a424f5613a Introduce Puppeteer.connect method (#264)
This patch:
- refactors Connection to use a single remote debugging URL instead of a
  pair of port and browserTargetId
- introduces Puppeteer.connect() method to attach to already running
  browser instance.

Fixes #238.
2017-08-15 14:29:42 -07:00
Andrey Lushnikov
24764df4c4 Emit 'error' event when page crashes (#266)
This patch starts emitting 'error' event when page crashes.
'error' events have special treatment in node, so page crashes
become observable for users.

Fixes #262.
2017-08-15 11:13:05 -07:00
JoelEinbinder
59256ee5ba Capitalize Chromium and Puppeteer (#263) 2017-08-15 00:14:12 -07:00
Andrey Lushnikov
fd325cd48c Add note about executablePath option to puppeteer.launch (#260) 2017-08-14 23:57:12 -07:00
Andrey Lushnikov
13e8580a34 Use puppeteer.launch instead of browser constructor (#255)
This patch:
- split browser launching logic from Browser into `lib/Launcher.js`
- introduce `puppeteer` namespace which currently has a single `launch`
  method to start a browser

With this patch, the browser is no longer created with the `new
Browser(..)` command. Instead, it should be "launched" via the
`puppeteer.launch` method:

```js
const puppeteer = require('puppeteer');
puppeteer.launch().then(async browser => {
  ...
});
```

With this approach browser instance lifetime matches the lifetime of
actual browser process. This helps us:
- remove proxy streams, e.g. browser.stderr and browser.stdout
- cleanup browser class and make it possible to connect to remote
  browser
- introduce events on the browser instance, e.g. 'page' event. In case
  of lazy-launching browser, we should've launch browser when an event
  listener is added, which is unneded comlpexity.
2017-08-14 18:08:06 -07:00
Andrey Lushnikov
13e0965407 Move emulation documentation under page.emulate method. (#253) 2017-08-13 00:47:01 -07:00
Andrey Lushnikov
4551afc6dc Introduce new interception API (#242)
This patch introduces new interception API, via killing InterceptedRequest and giving the `abort` and `continue` methods to the Request object.
2017-08-11 17:24:31 -07:00
Andrey Lushnikov
dbac6788ae Plumb default prompt value to the dialog (#243)
This patch:
- plumbs default prompt value to the dialog
- enables one more phantom test
2017-08-11 12:17:43 -07:00
Andrey Lushnikov
6347a049ba Rename Page.setInPageCallback into Page.addBinding (#236)
This seems to be a much better name which is actually used for a similar
purposes in chromium/v8.
2017-08-10 21:44:49 -07:00
Pavel Feldman
3a7741a172 Introduce page.emulate convenience wrapper (#231)
This patch:
- introduces Page.emulate convenience wrapper
- adds a screenshot-fullPage.js example
2017-08-10 18:42:30 -07:00
Eric Bidelman
8ccd10bfa2 Docs: add default networkIdleTimeout value (#234) 2017-08-10 14:49:34 -07:00
Andrey Lushnikov
e1d8a3781e Rename Page.navigate into Page.goto (#232)
Fixes #228.
2017-08-10 00:02:10 -07:00
Andrey Lushnikov
34b0095c10 Make interception work with redirects (#218)
This patch:
- changes interception API so that it better aligns with what we'd like to see
  in #121
- fixes the issue with redirect interception

Fixes #217.
2017-08-07 17:48:52 -07:00
Andrey Lushnikov
4f5cad921e [doc] Remove mention of broken javascript dialogs from api.md (#210) 2017-08-04 01:12:18 -07:00
Andrey Lushnikov
31224392bb Kill page.$ and page.$$ functions (#197)
page.$ and page.$$ conflicts with our ideas about element handles.

This patch removes functions in favor of future implementation.

References #111
2017-08-03 13:35:31 -07:00
JoelEinbinder
984e011cf0 Move path option into tracing.start (#192)
This consolidates all the tracing options in the tracing.start()
2017-08-02 15:41:05 -07:00
JoelEinbinder
bd72e40e73 Introduce page.tracing (#181)
This patch introduces page.tracing, which allows to start and stop
trace recording for a page. The trace could be then saved to file.
2017-08-02 10:45:11 -07:00