Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->158.0.8127.18<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->159.0.8154.13<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->27.2<!-- GEN:stop --> | ✅ | ✅ | ✅ |
| Firefox <!-- GEN:firefox-version -->159.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1520,10 +1520,13 @@ default void routeFromHAR(Path har) {
*
* @param offline Whether to emulate network being offline for the browser context.
*
* <p> <strong>NOTE:</strong> Offline emulation only affects requests that go through the browser's regular network stack, such as page navigations,
* {@code fetch()}, {@code XMLHttpRequest} and WebSockets. It does not affect WebRTC traffic: established {@code
* RTCPeerConnection}s keep sending and receiving media over UDP. To test WebRTC connection loss, interrupt the connection
* outside the browser, for example by stopping the TURN server or using an OS-level firewall.
* <p> <strong>NOTE:</strong> Offline emulation affects HTTP requests, such as page navigations, {@code fetch()} and {@code XMLHttpRequest}.WebSocket behavior depends on the browser and whether the connection is already established. Chromium and Firefox fail
* new WebSocket connections while offline, but do not close already-open connections. Chromium can defer incoming messages
* until the context goes back online, rather than lose them; Firefox can continue delivering messages while offline.
* WebKit can allow both new WebSocket connections and traffic on established connections while offline. Do not rely on
* offline emulation to test WebSocket message loss or connection closure.Offline emulation does not affect WebRTC traffic: established {@code RTCPeerConnection}s keep sending and receiving
* media over UDP. To test WebRTC connection loss, interrupt the connection outside the browser, for example by stopping
* the TURN server or using an OS-level firewall.
* @since v1.8
*/
void setOffline(boolean offline);
Expand Down
78 changes: 70 additions & 8 deletions playwright/src/main/java/com/microsoft/playwright/BrowserType.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,20 @@ class ConnectOverCDPOptions {
public @Nullable Path artifactsDir;
/**
* Additional HTTP headers to be sent with connect request. Optional.
*
* <p> When {@code endpointURL} is an extension URL such as {@code extension://chrome}, the headers are not sent. They are the
* options of the connection:
* <ul>
* <li> {@code x-playwright-extension-token} - the token of the extension. With the token, the user does not have to approve the
* connection. Without the token, the user must approve the connection before {@code timeout} expires, so set it to a value
* that gives the user enough time.</li>
* <li> {@code x-playwright-extension-client-name} - the name of the client that the extension shows to the user.</li>
* <li> {@code x-playwright-extension-tab-group} - pass {@code false} to keep the tabs out of a tab group.</li>
* <li> {@code x-playwright-extension-tab-group-title} - the title of the tab group.</li>
* <li> {@code x-playwright-extension-tab-group-color} - the color of the tab group: {@code green}, {@code blue}, {@code
* purple}, {@code orange}, {@code pink}, {@code cyan}, {@code yellow} or {@code red}.</li>
* <li> {@code x-playwright-extension-background} - pass {@code true} to keep the tabs from becoming active.</li>
* </ul>
*/
public @Nullable Map<String, String> headers;
/**
Expand Down Expand Up @@ -167,6 +181,20 @@ public ConnectOverCDPOptions setArtifactsDir(Path artifactsDir) {
}
/**
* Additional HTTP headers to be sent with connect request. Optional.
*
* <p> When {@code endpointURL} is an extension URL such as {@code extension://chrome}, the headers are not sent. They are the
* options of the connection:
* <ul>
* <li> {@code x-playwright-extension-token} - the token of the extension. With the token, the user does not have to approve the
* connection. Without the token, the user must approve the connection before {@code timeout} expires, so set it to a value
* that gives the user enough time.</li>
* <li> {@code x-playwright-extension-client-name} - the name of the client that the extension shows to the user.</li>
* <li> {@code x-playwright-extension-tab-group} - pass {@code false} to keep the tabs out of a tab group.</li>
* <li> {@code x-playwright-extension-tab-group-title} - the title of the tab group.</li>
* <li> {@code x-playwright-extension-tab-group-color} - the color of the tab group: {@code green}, {@code blue}, {@code
* purple}, {@code orange}, {@code pink}, {@code cyan}, {@code yellow} or {@code red}.</li>
* <li> {@code x-playwright-extension-background} - pass {@code true} to keep the tabs from becoming active.</li>
* </ul>
*/
public ConnectOverCDPOptions setHeaders(Map<String, String> headers) {
this.headers = headers;
Expand Down Expand Up @@ -1361,10 +1389,27 @@ default Browser connect(String endpoint) {
* @param endpointURL A CDP websocket endpoint or http url to connect to. For example {@code http://localhost:9222/} or {@code
* ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4}.
*
* <p> Alternatively, a browser channel name such as {@code chrome} or {@code msedge} to connect to a browser with remote
* debugging enabled in its default user data directory. On Linux, Playwright uses {@code CHROME_USER_DATA_DIR} when set.
* Otherwise, it uses {@code CHROME_CONFIG_HOME}, then {@code XDG_CONFIG_HOME}, then {@code ~/.config} to locate that
* directory.
* <p> Alternatively, a URL that tells which running browser to connect to:
* <ul>
* <li> {@code remote-debugging://<channel>} - a browser with remote debugging enabled, for example {@code
* remote-debugging://msedge}. The optional {@code userDataDir} parameter is the user data directory of the browser, when
* it is not the default one: {@code remote-debugging://chrome?userDataDir=/path/to/data}. A bare channel name such as
* {@code chrome} is the same as {@code remote-debugging://chrome}.</li>
* <li> {@code extension://<channel>/<profile directory>} - the tabs of a browser profile, through the <a
* href="https://chromewebstore.google.com/detail/playwright-extension/mmlmfjhmonkocbjadbfplnigmagldckm">Playwright
* Extension</a>, for example {@code extension://chrome/Profile 1}. Playwright opens the connect page of the extension in
* that profile, and the user selects the tabs to share. Without the profile directory, Playwright uses the {@code Default}
* profile. The optional parameters are {@code userDataDir}, the user data directory of the browser when it is not the
* default one, and {@code executablePath}, the path to the browser executable when it is not at the standard location:
* {@code extension://chromium?executablePath=/path/to/chrome&userDataDir=/path/to/data}. Pass the other options of this
* connection in {@code headers}.</li>
* </ul>
*
* <p> The values of {@code userDataDir} and {@code executablePath} must be URL-encoded, for example with {@code
* encodeURIComponent} or {@code URLSearchParams}. The channel is a browser channel name such as {@code chrome}, {@code
* chrome-beta} or {@code msedge}. The default user data directory of the channel is where the browser keeps its data. On
* Linux, Playwright uses {@code CHROME_USER_DATA_DIR} when set. Otherwise, it uses {@code CHROME_CONFIG_HOME}, then {@code
* XDG_CONFIG_HOME}, then {@code ~/.config} to locate that directory.
* @since v1.9
*/
default Browser connectOverCDP(String endpointURL) {
Expand Down Expand Up @@ -1395,10 +1440,27 @@ default Browser connectOverCDP(String endpointURL) {
* @param endpointURL A CDP websocket endpoint or http url to connect to. For example {@code http://localhost:9222/} or {@code
* ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4}.
*
* <p> Alternatively, a browser channel name such as {@code chrome} or {@code msedge} to connect to a browser with remote
* debugging enabled in its default user data directory. On Linux, Playwright uses {@code CHROME_USER_DATA_DIR} when set.
* Otherwise, it uses {@code CHROME_CONFIG_HOME}, then {@code XDG_CONFIG_HOME}, then {@code ~/.config} to locate that
* directory.
* <p> Alternatively, a URL that tells which running browser to connect to:
* <ul>
* <li> {@code remote-debugging://<channel>} - a browser with remote debugging enabled, for example {@code
* remote-debugging://msedge}. The optional {@code userDataDir} parameter is the user data directory of the browser, when
* it is not the default one: {@code remote-debugging://chrome?userDataDir=/path/to/data}. A bare channel name such as
* {@code chrome} is the same as {@code remote-debugging://chrome}.</li>
* <li> {@code extension://<channel>/<profile directory>} - the tabs of a browser profile, through the <a
* href="https://chromewebstore.google.com/detail/playwright-extension/mmlmfjhmonkocbjadbfplnigmagldckm">Playwright
* Extension</a>, for example {@code extension://chrome/Profile 1}. Playwright opens the connect page of the extension in
* that profile, and the user selects the tabs to share. Without the profile directory, Playwright uses the {@code Default}
* profile. The optional parameters are {@code userDataDir}, the user data directory of the browser when it is not the
* default one, and {@code executablePath}, the path to the browser executable when it is not at the standard location:
* {@code extension://chromium?executablePath=/path/to/chrome&userDataDir=/path/to/data}. Pass the other options of this
* connection in {@code headers}.</li>
* </ul>
*
* <p> The values of {@code userDataDir} and {@code executablePath} must be URL-encoded, for example with {@code
* encodeURIComponent} or {@code URLSearchParams}. The channel is a browser channel name such as {@code chrome}, {@code
* chrome-beta} or {@code msedge}. The default user data directory of the channel is where the browser keeps its data. On
* Linux, Playwright uses {@code CHROME_USER_DATA_DIR} when set. Otherwise, it uses {@code CHROME_CONFIG_HOME}, then {@code
* XDG_CONFIG_HOME}, then {@code ~/.config} to locate that directory.
* @since v1.9
*/
Browser connectOverCDP(String endpointURL, @Nullable ConnectOverCDPOptions options);
Expand Down
8 changes: 8 additions & 0 deletions playwright/src/main/java/com/microsoft/playwright/Frame.java
Original file line number Diff line number Diff line change
Expand Up @@ -3470,6 +3470,8 @@ default Locator getByAltText(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -3488,6 +3490,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -3504,6 +3508,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -3522,6 +3528,8 @@ default Locator getByLabel(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ default Locator getByAltText(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -528,6 +530,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -544,6 +548,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -562,6 +568,8 @@ default Locator getByLabel(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
* com.microsoft.playwright.Keyboard#up Keyboard.up()}, and {@link com.microsoft.playwright.Keyboard#insertText
* Keyboard.insertText()} to manually fire events as if they were generated from a real keyboard.
*
* <p> <strong>NOTE:</strong> Caps Lock state emulation is not supported. Pressing {@code CapsLock} dispatches keyboard events, but does not make
* subsequent lowercase input uppercase. To type uppercase text, pass uppercase characters to {@link
* com.microsoft.playwright.Locator#pressSequentially Locator.pressSequentially()} or {@link
* com.microsoft.playwright.Keyboard#type Keyboard.type()}.
*
* <p> An example of holding down {@code Shift} in order to select and delete some text:
* <pre>{@code
* page.keyboard().type("Hello World!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3700,6 +3700,8 @@ default Locator getByAltText(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -3718,6 +3720,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -3734,6 +3738,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -3752,6 +3758,8 @@ default Locator getByLabel(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand Down
8 changes: 8 additions & 0 deletions playwright/src/main/java/com/microsoft/playwright/Page.java
Original file line number Diff line number Diff line change
Expand Up @@ -5184,6 +5184,8 @@ default Locator getByAltText(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -5202,6 +5204,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -5218,6 +5222,8 @@ default Locator getByLabel(String text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand All @@ -5236,6 +5242,8 @@ default Locator getByLabel(Pattern text) {
* Allows locating input elements by the text of the associated {@code <label>} or {@code aria-labelledby} element, or by
* the {@code aria-label} attribute.
*
* <p> Associated {@code <label>} elements are also supported for form-associated custom elements.
*
* <p> <strong>Usage</strong>
*
* <p> For example, this method will find inputs by label "Username" and "Password" in the following DOM:
Expand Down
Loading
Loading