Commit graph

156 commits

Author SHA1 Message Date
Dmitry Gozman 19abc9bd9f
fix(dialogs): let click timeout, log information about dialogs (#2781)
We should not stall selector actions because of dialogs
and properly timeout instead. For this, we should not await
the handle.dispose() call because it will never happen
while dialog is shown.

Also, log information about dialogs to make it easier to debug.
2020-07-01 22:10:37 -07:00
Dmitry Gozman e8e45e8450
feat(dom): migrate innerText, innerHTML and getAttribute to tasks (#2782)
This ensures synchronous access to avoid element recycling.
2020-07-01 16:10:53 -07:00
Dmitry Gozman b54303a386
fix(textContent): make page.textContent(selector) atomic (#2717)
We now query selector and take textContent synchronously. This
avoids any issues with async processing: node being recycled,
detached, etc.

More methods will follow with the same atomic pattern.

Drive-by: fixed selector engine names being sometimes case-sensitive
and sometimes not.
2020-06-26 16:32:42 -07:00
Dmitry Gozman ab6a6c9b82
chore: run most actions through page._runAbortableTask (#2721)
This introduces a single place for future snapshots.
2020-06-25 16:57:21 -07:00
Pavel Feldman bab6833232
chore: introduce the experimental rpc implementation (#2720) 2020-06-25 16:05:36 -07:00
Dmitry Gozman 807dc1f324
fix(crash): improve documentation for crash, reject waitForEvent (#2694) 2020-06-25 09:53:56 -07:00
Pavel Feldman bc3050776e
chore: prepare library types for rpc (#2706) 2020-06-25 08:30:56 -07:00
Dmitry Gozman f111974ad6
chore: prepare parsed selectors to more tasks (#2696)
We currently have dispatchEventTask and waitForSelectorTask.
However, most selector-based operations make sense as tasks, to ensure
atomic execution, e.g. textContent(selector) or focus(selector).
This will fight hydration, elements recycling and other async issues.

In preparation, decouple tasks from selectors parsing so that
we can have common infrastructure for tasks.
2020-06-24 17:03:28 -07:00
Dmitry Gozman 39ce35e154
fix(errors): strict error handling around element operations (#2567)
- Gave all possible dom errors distinct names, and throw them on the node side.
- Separated errors into FatalDOMError and RetargetableDOMError.
  Fatal errors are unrecoverable. Retargetable errors
  could be resolved by requerying the selector.
- This exposed a number of unhandled 'notconnected' cases.
- Added helper functions to handle errors and ensure TypeScript catches
  unhandled ones.
2020-06-24 15:12:17 -07:00
Pavel Feldman fca514d74e
chore: move non-trivial types out of types.ts (#2680) 2020-06-23 14:51:06 -07:00
Pavel Feldman c220fc7f46
chore(logs): rework logs for simplicity (#2592) 2020-06-16 17:11:19 -07:00
Dmitry Gozman d4c466868b
chore: explicitly plumb various errors through the retries (#2554)
We are about to have more errors, so explicit plumbing helps with visibility.
2020-06-12 14:59:26 -07:00
Darío Kondratiuk e3f34f6ae2
fix(selectOption): allow passing null to unselect all (#2405) 2020-06-10 09:37:29 -07:00
Dmitry Gozman 80705ff5e9
chore: simplify logging a bit (#2512)
This merges a few classes and stops inheriting from InnerLogger.
2020-06-09 16:11:17 -07:00
Dmitry Gozman 5c3a275270
feat(debug): improve api logs (#2481) 2020-06-06 20:59:06 -07:00
Dmitry Gozman 3ec79e17fc
chore: simplify timeout handling in progress (#2487) 2020-06-05 15:53:30 -07:00
Dmitry Gozman 87e0c96ef2
chore: inverse FrameTask callbacks/promises (#2478)
Alternative way to handle this indirection.
2020-06-05 10:06:59 -07:00
Dmitry Gozman 1d37a10558
chore: migrate navigations to Progress (#2463) 2020-06-04 16:43:48 -07:00
Dmitry Gozman 1accb5141d
chore: convert more actions to Progress (#2444) 2020-06-03 11:23:24 -07:00
Dmitry Gozman f188b0a174
chore: migrate most actions to Progress (#2439) 2020-06-03 09:14:53 -07:00
Dmitry Gozman bf67245de6
feat(debug): stream logs from waitForSelector (#2434)
- we can now stream logs from InjectedScriptProgress to Progress;
- waitForSelector task uses it to report intermediate elements.
2020-06-01 15:48:23 -07:00
Dmitry Gozman b7df4d57a4
chore: migrate wait tasks to Progress (#2422) 2020-06-01 08:54:18 -07:00
Dmitry Gozman 8f350e4fe6
chore: make polling in page cancelable from node (#2399)
- unifies polling timeouts with everything else,
  based on the client time instead of the server time;
- prepares polling tasks for cancellation token
  behavior.

Unfortunately, RerunnableTask had to be rewritten almost
entirely.
2020-05-30 15:00:53 -07:00
Andrey Lushnikov 7a785ac268
fix: properly rewrite error message (#2392)
Error message is included in error's stack, so we should
re-write stack as well.

Fixes #2373
2020-05-28 16:33:31 -07:00
Andrey Lushnikov e312845ba9
fix: less confusing error message (#2305)
Fixes #2283
2020-05-19 17:47:46 -07:00
Andrey Lushnikov f24696be62
feat: add page convenience methods for textContent and getAttribute (#2235)
This patch adds:
- `page.innerText()` / `frame.innerText()`
- `page.innerHTML()` / `frame.innerHTML()`
- `page.textContent()` / `frame.textContent()`
- `page.getAttribute()` / `frame.getAttribute()`

Fixes #2143
2020-05-18 17:58:23 -07:00
Pavel Feldman 2bd427ad1d
feat(exposeBinding): a more powerful exposeFunction with source attribution (#2263) 2020-05-18 14:28:06 -07:00
Dmitry Gozman 4bf5742d47
fix(chromium): abort fetch requests that lack networkId (#2254)
These requests are usually internal ones, and we can safely abort them.
An example would be DevTools loading cached resources to show the content.
There will never be a matching Network.requestWillBeSent event, so we do not
report them to the user.
2020-05-15 15:22:29 -07:00
Pavel Feldman 99b7aaace8
chore: refactor injected script harness (#2259) 2020-05-15 15:21:49 -07:00
Dmitry Gozman 650d73445c
fix(actions): do not wait for the created popups (#2219)
Since we are recommending Promise.all pattern anyway, this special
logic just adds to the possibility of timeout if something goes wrong.

For example, Firefox sometimes send Page.willOpenNewWindowAsynchronously
later than the new target arrives and input action just hangs.
2020-05-13 17:20:33 -07:00
Pavel Feldman 8e59031078
chore: introduce debugAssert (#2160) 2020-05-08 10:37:54 -07:00
Pavel Feldman 1c17929bd8
chore: add input logging and timeout debugging hints (#2109) 2020-05-04 21:44:33 -07:00
Pavel Feldman bcce48362a
api(waitForSelector): make "state: visible" default, includes rename to state (#2091) 2020-05-04 11:03:44 -07:00
Dmitry Gozman 953dd36d38
feat(api): remove 'mutation' polling option (#2048)
It is not compatible with shadow dom.
2020-04-29 21:34:14 -07:00
Yury Semikhatsky 5993a6a0e0
fix: throw from eval methods if >1 argument is passed (#2043) 2020-04-29 18:35:04 -07:00
Pavel Feldman 7f8aa703dd
api(waitFor): remove waitFor, use specialized wait functions (#1995) 2020-04-27 12:08:29 -07:00
Pavel Feldman c1c0237d4e
api(dispatchEvent): page, frame and handle versions added (#1932) 2020-04-23 14:58:37 -07:00
Yury Semikhatsky 00e8d88777
fix: do not auto wait for downloads (#1921) 2020-04-22 15:08:39 -07:00
Pavel Feldman 6ecac8c164
chore: restore networkidle0 alias (#1920) 2020-04-22 10:52:01 -07:00
Pavel Feldman 0656771167
api(networkidle): remove networkidle2 (#1883) 2020-04-20 16:52:26 -07:00
Pavel Feldman 1f43ae692f
feat(logging): introduce logger sink api (#1861) 2020-04-20 07:52:26 -07:00
Dmitry Gozman 55b4bc99bd
feat(actions): requery the element when it was detached during the action (#1853) 2020-04-18 18:29:31 -07:00
Yury Semikhatsky 2b96b85e05
fix(firefox): throw error when added script blocked by CSP (#1841) 2020-04-17 08:51:54 -07:00
Pavel Feldman a248430af8
reapply api(waitUntil): remove waitUntil options from the actions (#1842) 2020-04-16 20:31:04 -07:00
Andrey Lushnikov 31460b18b8
Revert "api(waitUntil): remove waitUntil options from the actions (#1834)" (#1840)
This reverts commit d0b8710670.

Reason: multiple test failures on all Linux bots
- https://app.circleci.com/pipelines/github/microsoft/playwright/613/workflows/50dc6e2d-23b0-41d2-9765-42983b0ed91d/jobs/610
- https://travis-ci.com/github/microsoft/playwright/builds/160648417
- https://github.com/microsoft/playwright/pull/1839/checks?check_run_id=594015893
2020-04-16 18:46:10 -07:00
Pavel Feldman d0b8710670
api(waitUntil): remove waitUntil options from the actions (#1834) 2020-04-16 16:04:10 -07:00
Dmitry Gozman f5942295d4
feat(api): wait for popups and downloads when performing actions (#1744) 2020-04-16 13:09:24 -07:00
Pavel Feldman 2280126344
api(setInputFiles): introduce page/frame helpers, document, break compat (#1818) 2020-04-16 10:25:28 -07:00
Pavel Feldman 9d05038a82
feat(hints): hint at how waitFor(time) is bad for production (#1781) 2020-04-14 15:00:10 -07:00
Joel Einbinder a7572c7f09
feat: nicer error message for page.addScriptTag (#1754) 2020-04-12 18:46:53 -07:00