|
25 | 25 | | <a href="#karate-chrome">Docker / <code>karate-chrome</code></a>
|
26 | 26 | | <a href="#driver-types">Driver Types</a>
|
27 | 27 | | <a href="#playwright">Playwright</a>
|
| 28 | + | <a href="#playwright-legacy">Playwright Legacy</a> |
28 | 29 | | <a href="#timeout"><code>timeout()</code></a>
|
29 | 30 | | <a href="#driversessionid"><code>driver.sessionId</code></a>
|
30 | 31 | </td>
|
@@ -346,7 +347,36 @@ Note that some capabilities such as "headless" may be possible via the command-l
|
346 | 347 |
|
347 | 348 | Also see [`driver.sessionId`](#driversessionid).
|
348 | 349 |
|
| 350 | + |
349 | 351 | ### Playwright
|
| 352 | + |
| 353 | +Driver that leverages [Playwright](https://playwright.dev) java native APIs. |
| 354 | + |
| 355 | +To use it, add the following dependency: |
| 356 | +```xml |
| 357 | +<dependency> |
| 358 | + <groupId>io.karate</groupId> |
| 359 | + <artifactId>karate-playwright</artifactId> |
| 360 | + <scope>test</scope> |
| 361 | +</dependency> |
| 362 | +``` |
| 363 | + |
| 364 | +And make sure it is declared before `io.karate:karate-core`. |
| 365 | + |
| 366 | +A server will be automatically started and made available to Karate without any extra-script. If you have one pre-started, you can still use the [`playwrightUrl`](#configure-driver) driver config. |
| 367 | + |
| 368 | +### `playwrightOptions` |
| 369 | +When using [Playwright](#playwright) you can omit this in which case Karate will default to Chrome (within Playwright) and the default browser window size. |
| 370 | + |
| 371 | +This can take the following keys: |
| 372 | +* `browserType` - defaults to `chromium`, can be set to the other [types that Playwright supports](https://playwright.dev/docs/core-concepts#browser), e.g. `firefox` and `webkit` |
| 373 | +* `context` - JSON which will be passed as the argument of the Playwright [`browser.newContext()`](https://playwright.dev/docs/api/class-browser#browsernewcontextoptions) call, needed typically to set the page dimensions |
| 374 | +* `channel` - defaults to chrome, for the `chromium` browserType, allows to specify which [flavor](https://playwright.dev/docs/browsers#google-chrome--microsoft-edge) to use |
| 375 | +* `installBrowsers` - defaults to `true`, whether or not all the supported browsers will be downloaded and installed by Playwright (once). |
| 376 | + |
| 377 | +Note that there is a top-level config flag for `headless` mode. The default is: `* configure driver = { headless: false }` |
| 378 | + |
| 379 | +### Playwright Legacy |
350 | 380 | To use [Playwright](https://playwright.dev), you need to start a Playwright server. If you have one pre-started, you need to use the [`playwrightUrl`](#configure-driver) driver config.
|
351 | 381 |
|
352 | 382 | Or you can set up an executable that can do it and log the URL to the console when the server is ready. The websocket URL will look like this: `ws://127.0.0.1:4444/0e0bd1c0bb2d4eb550d02c91046dd6e0`.
|
@@ -399,14 +429,6 @@ For convenience, Karate assumes by default that the executable name is `playwrig
|
399 | 429 |
|
400 | 430 | Based on the above details, you should be able to come up with a custom strategy to connect Karate to Playwright. And you can consider a [`driverTarget`](#custom-target) approach for complex needs such as using a Docker container for CI.
|
401 | 431 |
|
402 |
| -### `playwrightOptions` |
403 |
| -When using [Playwright](#playwright) you can omit this in which case Karate will default to Chrome (within Playwright) and the default browser window size. |
404 |
| - |
405 |
| -This can take the following keys: |
406 |
| -* `browserType` - defaults to `chromium`, can be set to the other [types that Playwright supports](https://playwright.dev/docs/core-concepts#browser), e.g. `firefox` and `webkit` |
407 |
| -* `context` - JSON which will be passed as the argument of the Playwright [`browser.newContext()`](https://playwright.dev/docs/api/class-browser#browsernewcontextoptions) call, needed typically to set the page dimensions |
408 |
| - |
409 |
| -Note that there is a top-level config flag for `headless` mode. The default is: `* configure driver = { headless: false }` |
410 | 432 |
|
411 | 433 | ## `configure driverTarget`
|
412 | 434 | The [`configure driver`](#configure-driver) options are fine for testing on "`localhost`" and when not in `headless` mode. But when the time comes for running your web-UI automation tests on a continuous integration server, things get interesting. To support all the various options such as Docker, headless Chrome, cloud-providers etc., Karate introduces the concept of a pluggable [`Target`](src/main/java/com/intuit/karate/driver/Target.java) where you just have to implement two methods:
|
@@ -1950,7 +1972,7 @@ Scenario:
|
1950 | 1972 | * screenshot()
|
1951 | 1973 | ```
|
1952 | 1974 |
|
1953 |
| -* `driver.intercept()` is supported only for the driver type `chrome` |
| 1975 | +* `driver.intercept()` is fully supported only for the driver type `chrome`. [`Playwright`](#playwright) supports only [urlPatterns](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#type-RequestPattern) |
1954 | 1976 | * you can route multiple URL patterns to the same Karate mock-feature, the format of each array-element under `patterns` can be found [here](https://chromedevtools.github.io/devtools-protocol/tot/Fetch/#type-RequestPattern).
|
1955 | 1977 | * the `*` wildcard (most likely what you need) will match any number of characters, e.g. `*myhost/some/path/*`
|
1956 | 1978 | * `?` will match any single character
|
|
0 commit comments