Commit Graph

68 Commits

Author SHA1 Message Date
Sergii Rudenko
8c93084316 docs(examples/readme.md): Add one more link to the examples repository (#1807)
This patch adds link to the https://github.com/checkly/puppeteer-examples
2018-01-16 14:05:28 -08:00
Andrey Lushnikov
d68033aeca
chore(examples): indent all examples (#1783)
Indented examples are easier to read.
2018-01-11 13:42:01 -08:00
Thomas Broadley
efbc52a4b7 docs: fix typos (#1647) 2017-12-27 20:04:11 -07:00
Andrey Lushnikov
b73737302a
fix: convert all getters to methods (#1621)
The patch converts all the getters in the codebase into the methods.
For example, the `request.url` getter becomes the `request.url()`
method.

This is done in order to unify the API and make it more predictable.
The general rule for all further changes would be:
- there are no getters/fields exposed in the api
- the only exceptions are "namespaces", e.g. `page.keyboard`

Fixes #280.

BREAKING CHANGE:
This patch ditches getters and replaces them with methods throughout
the API. The following methods were added instead of the fields:
- dialog.type()
- consoleMessage.args()
- consoleMessage.text()
- consoleMessage.type()
- request.headers()
- request.method()
- request.postData()
- request.resourceType()
- request.url()
- response.headers()
- response.ok()
- response.status()
- response.url()
2017-12-18 17:05:57 -08:00
Eric Bidelman
cb1cb695a5 chore(search) - search developers.google.com for "Headess chrome" articles (#1586)
Adds back a search demo. I chose developers.google.com b/c the protocol viewer uses shadow dom. Gets a bit confusing.

Fixes #1578
2017-12-14 19:13:27 -08:00
yujiosaka
4c588818a8 doc: Add headless-chrome-crawler to example's README (#1585)
Fixes #1582
2017-12-14 19:10:25 -08:00
Andrey Lushnikov
ea5da00755
chore: remove search.js example (#1564)
The example is violating the TOS of google.com

Fix #1557
2017-12-08 19:04:09 -08:00
Eric Bidelman
8c9332b62e docs(Readme): add loading extensions example (#1308)
This patch adds a tips-and-tricks section to the `readme.md` that explains
how to load extension to puppeteer.
2017-11-07 13:19:54 -08:00
Alessio Occhipinti
bdd5718630 docs(examples): added pupperender (#1293)
* doc(examples): added pupperender

* review fixes

* review fixes 2
2017-11-06 13:13:27 -08:00
Michael Stillwell
0bb2157743 Explain how to run examples (#1226)
* Explain how to run examples

* Update README.md

* Update README.md
2017-10-31 14:06:20 -07:00
Eric Bidelman
3bf18f26a2 chore(examples): use news.google.com for block-images.js (#1192)
Addresses insecure content errors on try-puppeteer

ebidel/try-puppeteer#7
2017-10-27 12:06:46 -07:00
Andrew Apicello
f9b017efaa chore(examples): update search example (#1181)
The search bar was not fully loaded and therefore "puppeteer" could not be entered into the submit field.

This patch starts waiting for the input element to be rendered to ensure this
element is loaded before attempting to populate it.
2017-10-27 02:10:35 -07:00
Andrey Lushnikov
ce005d480c feat(Chromium): Roll chromium to r511134 (#1153)
This roll includes:
- crrev.com/510651 that changes request interception methods in protocol
- s/Page.setRequestInterceptionEnabled/Page.setRequestInterception

BREAKING CHANGE

Page.setRequestInterceptionEnabled is renamed into
Page.setRequestInterception.
2017-10-24 14:45:03 -07:00
Andrey Lushnikov
ce8a952044 refactor: migrate NavigatorWatcher to lifecycle events (#1141)
This patch:
- migrates navigation watcher to use protocol-issued lifecycle events.
- removes `networkIdleTimeout` and `networkIdleInflight` options for
  `page.goto` method
- adds a new `networkidle0` value to the waitUntil option of navigation
  methods

References #728.

BREAKING CHANGE:

As an implication of this new approach, the `networkIdleTimeout` and
`networkIdleInflight` options are no longer supported. Interested
clients should implement the behavior themselves using the `request` and
`response` events.
2017-10-23 18:10:59 -07:00
rmzg
8717203fb2 chore(examples): Fixed a typo in examples/proxy.js (#1073) 2017-10-17 17:36:25 -07:00
Sashiyama Yoshiki
fbee98aa51 chore(examples): add missing argument to search example (#1066)
Fixes #1059.
2017-10-17 15:07:16 -07:00
Andrey Lushnikov
c3fb367148 fix(Request): convert resourceType to all small-caps (#990)
This patch moves resourceType to be all small-caps. This aligns
with our convention that all string constants should be smallcaps.

BREAKING CHANGE: this patch changes the constants of the
request.resourceType to be all small-caps.
2017-10-10 10:53:37 -07:00
Adi Prasetyo
611f51bda5 [doc] Fix thal link (#806)
This patch adds missing protocol to the link in example's README.md
2017-09-18 06:53:36 -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
Eric Bidelman
f11e09d0d4 resources.md -> readme.md so it renders on /examples (#753)
* resources.md -> index.md so it renders on /examples

* Rename index.md to README.md
2017-09-11 11:41:48 -07:00
Alessio Occhipinti
568b7bd47d Proposal: adding RESOURCES.md for examples (#743)
* Create RESOURCES.md

* Update RESOURCES.md
2017-09-11 11:34:06 -07:00
Eric Bidelman
30541cc087 block-images example: use reuters.com (#747)
Due to https://github.com/GoogleChrome/puppeteer/issues/746. The screenshot news.google.com isn't "full page", so that may be confusing to folks.
2017-09-11 10:16:57 -07:00
Eric Bidelman
272fb4d993 block-images example: switch from bbc to news.google.com (#708) 2017-09-07 12:35:52 -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
Eric Bidelman
4e3b6a1f57 Example: add listen for custom event on page load (#529)
* Example: add listen for custom event on page load

* correct pptr path
2017-08-24 23:33:31 -07:00
Vse Mozhet Byt
60ace82875 add 'use strict'; to examples (#530)
This patch:
- adds 'use strict'; to examples
- enforces 'use strict' in examples with .eslintrc.js
2017-08-24 17:33:41 -07:00
Andrey Lushnikov
a5eca57f4a Add proxy server example (#427) 2017-08-20 17:13:11 -07:00
Florian Reuschel
3b03fdd2d0 example 'block images' - make extension check case insensitive (#401) 2017-08-20 14:33:22 -07:00
Vse Mozhet Byt
7796ca50ee examples: replace let with const (#403) 2017-08-20 12:38:10 -07:00
Noriaki UCHIYAMA
21aa0a2390 example 'block images' - fix typo and add other extensions (#334)
* fix typo and add extensions to example 'block images'

* fix code style, keep the newline at EOF
2017-08-17 09:39:40 -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
JoelEinbinder
53baed6af6 Google search example (#220)
Add google search example.

References #178
2017-08-11 01:41:42 -07:00
Andrey Lushnikov
25465525c1 Fix full page screenshot example (#237)
This patch aligns the example with our style in `examples/` folder, and also starts to use page.goto instead of page.navigate
2017-08-10 21:44:27 -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
1ee47d868b Doc polish. Example consistency (#233) 2017-08-10 18:31:54 -07:00
Andrey Lushnikov
e1d8a3781e Rename Page.navigate into Page.goto (#232)
Fixes #228.
2017-08-10 00:02:10 -07:00
Andrey Lushnikov
29adc5dc80 [examples] get rid of old examples
This patch:
- removes old phantom-js examples
- adds an example to load page without images

References #178
2017-08-08 00:44:15 -07:00
JoelEinbinder
104455c75a Remove unrandomize example (#221) 2017-08-07 23:50:25 -07:00
Andrey Lushnikov
4eedc10cfa Add pdf.js example (#216)
add pdf.js example
2017-08-07 14:55:45 -07:00
JoelEinbinder
e6d8fca7cd Lint examples, again #178 (#190) 2017-08-02 15:03:26 -07:00
JoelEinbinder
0218960713 Revert "lint examples #178 (#182)" (#183)
This reverts commit 8c220654e8.
2017-08-02 01:26:02 -07:00
JoelEinbinder
8c220654e8 lint examples #178 (#182)
This patch enables lint in `examples/` folder.
2017-08-02 01:13:44 -07:00
Andrey Lushnikov
d4c5aee5a8 Rename page.evaluateOnInitialized into page.evaluateOnNewDocument
This patch renames page.evaluateOnInitialized into
page.evaluateOnNewDocument to better align with the protocol and with
what the method is actually doing.

Fixes #119.
2017-07-25 00:17:56 -07:00
Andrey Lushnikov
2ca08b032b Rename Page's 'consolemessage' event into 'console'
This patch:
- renames 'consolemessage' event into 'console'
- improves on 'console' event documentation

References #39.
2017-07-17 20:38:11 -07:00
Pavel Feldman
895f69d17a Add emulation for named devices. (#72)
This patch introduces page emulation, making it possible to emulate different devices.
2017-07-17 18:13:04 -07:00
Andrey Lushnikov
279cd4c9fb Remote Browser's remoteDebuggingPort option
This patch remove remoteDebuggingPort option. Instead, browser
is launched with '--remote-debugging-port=0' flag, letting browser
to pick any port. The puppeteer reads the port number from the
browser's stderr stream.

This change cuts average browser start time from 300ms to 250ms
on my machine. This happens since puppeteer doesn't have to probe
network once every 100ms, waiting for the remote debugging server to
instantiate.

Fixes #21.
2017-07-11 08:30:41 -07:00
Paul Irish
6c7ae41ae6 fix page.injectFile and add test. (#52)
This line within `injectFile` wasn't doing much of anything: 

```js
let expression = fs.readFile(filePath, 'utf8', (err, data) => callback({err, data}));
```

* That's fixed.
* A path error in examples/features.js is fixed.
* Test added for injectFile.
2017-07-07 02:09:23 +03:00
Andrey Lushnikov
7b59a89695 Implement Request object
This patch does a step towards Fetch API:
- implements Request object to some extend. The Request object will be
  sent in RequestWillBeSent event.
- implements InterceptedRequest which extends from Request and allows
  for request modification. The InterceptedRequest does not
  conform to Fetch API spec - there seems to be nothing related to
  amending in-flight request.
- adds test to make sure that request can change headers.

References #26
2017-06-28 01:41:42 -07:00
Pavel Feldman
8e0a3ac6d9 Make InPageCallback async (#24)
Fixes #20
2017-06-21 14:11:52 -07:00
Andrey Lushnikov
fce6b71d8e Cleanup usages of Page.saveScreenshot of 3b0bc080
The `Page.saveScreenshot` method was removed in favor of a `path`
option in the `Page.screenshot` method.
2017-06-21 14:11:52 -07:00