Skip to content

Commit

Permalink
feat: roll driver, implement new APIs (microsoft#1142)
Browse files Browse the repository at this point in the history
  • Loading branch information
yury-s authored Dec 19, 2022
1 parent 048bca9 commit 4efa174
Show file tree
Hide file tree
Showing 47 changed files with 3,449 additions and 2,825 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom

| | Linux | macOS | Windows |
| :--- | :---: | :---: | :---: |
| Chromium <!-- GEN:chromium-version -->108.0.5359.29<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Chromium <!-- GEN:chromium-version -->109.0.5414.46<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| WebKit <!-- GEN:webkit-version -->16.4<!-- GEN:stop --> ||||
| Firefox <!-- GEN:firefox-version -->106.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| Firefox <!-- GEN:firefox-version -->107.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |

Headless execution is supported for all the browsers on all platforms. Check out [system requirements](https://playwright.dev/java/docs/next/intro/#system-requirements) for details.

Expand Down
32 changes: 16 additions & 16 deletions playwright/src/main/java/com/microsoft/playwright/APIRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ class NewContextOptions {
*/
public Proxy proxy;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()}. Either a path to the file with saved storage, or the value returned by one of {@link
* BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()} methods.
* Populates context with given storage state. This option can be used to initialize context with logged-in
* information obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link
* APIRequestContext#storageState APIRequestContext.storageState()}. Either a path to the file with saved storage, or the
* value returned by one of {@link BrowserContext#storageState BrowserContext.storageState()} or {@link
* APIRequestContext#storageState APIRequestContext.storageState()} methods.
*/
public String storageState;
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
* Populates context with given storage state. This option can be used to initialize context with logged-in
* information obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved
* storage state.
*/
public Path storageStatePath;
/**
Expand Down Expand Up @@ -136,20 +136,20 @@ public NewContextOptions setProxy(Proxy proxy) {
return this;
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()}. Either a path to the file with saved storage, or the value returned by one of {@link
* BrowserContext#storageState BrowserContext.storageState()} or {@link APIRequestContext#storageState
* APIRequestContext.storageState()} methods.
* Populates context with given storage state. This option can be used to initialize context with logged-in
* information obtained via {@link BrowserContext#storageState BrowserContext.storageState()} or {@link
* APIRequestContext#storageState APIRequestContext.storageState()}. Either a path to the file with saved storage, or the
* value returned by one of {@link BrowserContext#storageState BrowserContext.storageState()} or {@link
* APIRequestContext#storageState APIRequestContext.storageState()} methods.
*/
public NewContextOptions setStorageState(String storageState) {
this.storageState = storageState;
return this;
}
/**
* Populates context with given storage state. This option can be used to initialize context with logged-in information
* obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved storage
* state.
* Populates context with given storage state. This option can be used to initialize context with logged-in
* information obtained via {@link BrowserContext#storageState BrowserContext.storageState()}. Path to the file with saved
* storage state.
*/
public NewContextOptions setStorageStatePath(Path storageStatePath) {
this.storageStatePath = storageStatePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.nio.file.Path;

/**
* This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services, prepare
* environment or the service to your e2e test.
* This API is used for the Web API testing. You can use it to trigger API endpoints, configure micro-services,
* prepare environment or the service to your e2e test.
*
* <p> Each Playwright browser context has associated with it {@code APIRequestContext} instance which shares cookie storage with the
* browser context and can be accessed via {@link BrowserContext#request BrowserContext.request()} or {@link Page#request
Expand All @@ -36,8 +36,8 @@
* automatically update {@code BrowserContext} cookies and requests made from the page will pick them up. This means that if you
* log in using this API, your e2e test will be logged in and vice versa.
*
* <p> If you want API requests to not interfere with the browser cookies you should create a new {@code APIRequestContext} by
* calling {@link APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext} object will have its own
* <p> If you want API requests to not interfere with the browser cookies you should create a new {@code APIRequestContext}
* by calling {@link APIRequest#newContext APIRequest.newContext()}. Such {@code APIRequestContext} object will have its own
* isolated cookie storage.
*/
public interface APIRequestContext {
Expand Down Expand Up @@ -83,10 +83,11 @@ default APIResponse delete(String url) {
*/
void dispose();
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects.
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and
* update context cookies from the response. The method will automatically follow redirects. JSON objects can be passed
* directly to the request.
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
Expand Down Expand Up @@ -117,10 +118,11 @@ default APIResponse fetch(String urlOrRequest) {
return fetch(urlOrRequest, null);
}
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects.
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and
* update context cookies from the response. The method will automatically follow redirects. JSON objects can be passed
* directly to the request.
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
Expand Down Expand Up @@ -150,10 +152,11 @@ default APIResponse fetch(String urlOrRequest) {
*/
APIResponse fetch(String urlOrRequest, RequestOptions params);
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects.
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and
* update context cookies from the response. The method will automatically follow redirects. JSON objects can be passed
* directly to the request.
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
Expand Down Expand Up @@ -184,10 +187,11 @@ default APIResponse fetch(Request urlOrRequest) {
return fetch(urlOrRequest, null);
}
/**
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and update
* context cookies from the response. The method will automatically follow redirects.
* Sends HTTP(S) request and returns its response. The method will populate request cookies from the context and
* update context cookies from the response. The method will automatically follow redirects. JSON objects can be passed
* directly to the request.
*
* <p> JSON objects can be passed directly to the request:
* <p> **Usage**
* <pre>{@code
* Map<String, Object> data = new HashMap();
* data.put("title", "Book Title");
Expand Down Expand Up @@ -221,6 +225,8 @@ default APIResponse fetch(Request urlOrRequest) {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> **Usage**
*
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
* <pre>{@code
* request.get("https://example.com/api/getText", RequestOptions.create()
Expand All @@ -238,6 +244,8 @@ default APIResponse get(String url) {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> **Usage**
*
* <p> Request parameters can be configured with {@code params} option, they will be serialized into the URL search parameters:
* <pre>{@code
* request.get("https://example.com/api/getText", RequestOptions.create()
Expand Down Expand Up @@ -292,6 +300,8 @@ default APIResponse patch(String url) {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> **Usage**
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
* Map<String, Object> data = new HashMap();
Expand Down Expand Up @@ -335,6 +345,8 @@ default APIResponse post(String url) {
* response. The method will populate request cookies from the context and update context cookies from the response. The
* method will automatically follow redirects.
*
* <p> **Usage**
*
* <p> JSON objects can be passed directly to the request:
* <pre>{@code
* Map<String, Object> data = new HashMap();
Expand Down
Loading

0 comments on commit 4efa174

Please sign in to comment.