feat: roll to 1.18.0-alpha-nov-29-2021 (#725)
This commit is contained in:
@@ -11,7 +11,7 @@ Playwright is a Java library to automate [Chromium](https://www.chromium.org/Hom
|
||||
|
||||
| | Linux | macOS | Windows |
|
||||
| :--- | :---: | :---: | :---: |
|
||||
| Chromium <!-- GEN:chromium-version -->98.0.4708.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| Chromium <!-- GEN:chromium-version -->98.0.4730.0<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
| WebKit <!-- GEN:webkit-version -->15.4<!-- GEN:stop --> | ✅ | ✅ | ✅ |
|
||||
| Firefox <!-- GEN:firefox-version -->94.0.1<!-- GEN:stop --> | :white_check_mark: | :white_check_mark: | :white_check_mark: |
|
||||
|
||||
|
||||
@@ -49,6 +49,13 @@ import com.microsoft.playwright.impl.PageAssertionsImpl;
|
||||
* <p> By default, the timeout for assertions is set to 5 seconds.
|
||||
*
|
||||
* <p> To use Playwright assertions add the following dependency into the {@code pom.xml} of your Maven project:
|
||||
* <pre>{@code
|
||||
* <dependency>
|
||||
* <groupId>com.microsoft.playwright</groupId>
|
||||
* <artifactId>assertions</artifactId>
|
||||
* <version>1.17.0</version>
|
||||
* </dependency>
|
||||
* }</pre>
|
||||
*/
|
||||
public interface PlaywrightAssertions {
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,9 @@ import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Exposes API that can be used for the Web API testing.
|
||||
* Exposes API that can be used for the Web API testing. Each Playwright browser context has a APIRequestContext instance
|
||||
* attached which shares cookies with the page context. Its also possible to create a new APIRequestContext instance
|
||||
* manually. For more information see <a href="https://playwright.dev/java/docs/class-apirequestcontext">here</a>.
|
||||
*/
|
||||
public interface APIRequest {
|
||||
class NewContextOptions {
|
||||
|
||||
@@ -424,6 +424,107 @@ public interface Locator {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class DragToOptions {
|
||||
/**
|
||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
|
||||
* {@code false}.
|
||||
*/
|
||||
public Boolean force;
|
||||
/**
|
||||
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
|
||||
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
|
||||
* inaccessible pages. Defaults to {@code false}.
|
||||
*/
|
||||
public Boolean noWaitAfter;
|
||||
/**
|
||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||
* specified, some visible point of the element is used.
|
||||
*/
|
||||
public Position sourcePosition;
|
||||
/**
|
||||
* Drops on the target element at this point relative to the top-left corner of the element's padding box. If not
|
||||
* specified, some visible point of the element is used.
|
||||
*/
|
||||
public Position targetPosition;
|
||||
/**
|
||||
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
|
||||
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
|
||||
* Page.setDefaultTimeout()} methods.
|
||||
*/
|
||||
public Double timeout;
|
||||
/**
|
||||
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
|
||||
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
|
||||
* performing it.
|
||||
*/
|
||||
public Boolean trial;
|
||||
|
||||
/**
|
||||
* Whether to bypass the <a href="https://playwright.dev/java/docs/actionability/">actionability</a> checks. Defaults to
|
||||
* {@code false}.
|
||||
*/
|
||||
public DragToOptions setForce(boolean force) {
|
||||
this.force = force;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Actions that initiate navigations are waiting for these navigations to happen and for pages to start loading. You can
|
||||
* opt out of waiting via setting this flag. You would only need this option in the exceptional cases such as navigating to
|
||||
* inaccessible pages. Defaults to {@code false}.
|
||||
*/
|
||||
public DragToOptions setNoWaitAfter(boolean noWaitAfter) {
|
||||
this.noWaitAfter = noWaitAfter;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||
* specified, some visible point of the element is used.
|
||||
*/
|
||||
public DragToOptions setSourcePosition(double x, double y) {
|
||||
return setSourcePosition(new Position(x, y));
|
||||
}
|
||||
/**
|
||||
* Clicks on the source element at this point relative to the top-left corner of the element's padding box. If not
|
||||
* specified, some visible point of the element is used.
|
||||
*/
|
||||
public DragToOptions setSourcePosition(Position sourcePosition) {
|
||||
this.sourcePosition = sourcePosition;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Drops on the target element at this point relative to the top-left corner of the element's padding box. If not
|
||||
* specified, some visible point of the element is used.
|
||||
*/
|
||||
public DragToOptions setTargetPosition(double x, double y) {
|
||||
return setTargetPosition(new Position(x, y));
|
||||
}
|
||||
/**
|
||||
* Drops on the target element at this point relative to the top-left corner of the element's padding box. If not
|
||||
* specified, some visible point of the element is used.
|
||||
*/
|
||||
public DragToOptions setTargetPosition(Position targetPosition) {
|
||||
this.targetPosition = targetPosition;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
|
||||
* using the {@link BrowserContext#setDefaultTimeout BrowserContext.setDefaultTimeout()} or {@link Page#setDefaultTimeout
|
||||
* Page.setDefaultTimeout()} methods.
|
||||
*/
|
||||
public DragToOptions setTimeout(double timeout) {
|
||||
this.timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* When set, this method only performs the <a href="https://playwright.dev/java/docs/actionability/">actionability</a>
|
||||
* checks and skips the action. Defaults to {@code false}. Useful to wait until the element is ready for the action without
|
||||
* performing it.
|
||||
*/
|
||||
public DragToOptions setTrial(boolean trial) {
|
||||
this.trial = trial;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
class ElementHandleOptions {
|
||||
/**
|
||||
* Maximum time in milliseconds, defaults to 30 seconds, pass {@code 0} to disable timeout. The default value can be changed by
|
||||
@@ -1674,6 +1775,20 @@ public interface Locator {
|
||||
* @param eventInit Optional event-specific initialization properties.
|
||||
*/
|
||||
void dispatchEvent(String type, Object eventInit, DispatchEventOptions options);
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param target Locator of the element to drag to.
|
||||
*/
|
||||
default void dragTo(Locator target) {
|
||||
dragTo(target, null);
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param target Locator of the element to drag to.
|
||||
*/
|
||||
void dragTo(Locator target, DragToOptions options);
|
||||
/**
|
||||
* Resolves given locator to the first matching DOM element. If no elements matching the query are visible, waits for them
|
||||
* up to a given timeout. If multiple elements match the selector, throws.
|
||||
|
||||
@@ -108,9 +108,6 @@ class APIRequestContextImpl extends ChannelOwner implements APIRequestContext {
|
||||
params.addProperty("ignoreHTTPSErrors", options.ignoreHTTPSErrors);
|
||||
}
|
||||
JsonObject json = sendMessage("fetch", params).getAsJsonObject();
|
||||
if (json.has("error")) {
|
||||
throw new PlaywrightException(json.get("error").getAsString());
|
||||
}
|
||||
return new APIResponseImpl(this, json.getAsJsonObject("response"));
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,16 @@ class LocatorImpl implements Locator {
|
||||
frame.dispatchEvent(selector, type, eventInit, convertType(options, Frame.DispatchEventOptions.class).setStrict(true));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dragTo(Locator target, DragToOptions options) {
|
||||
if (options == null) {
|
||||
options = new DragToOptions();
|
||||
}
|
||||
Frame.DragAndDropOptions frameOptions = convertType(options, Frame.DragAndDropOptions.class);
|
||||
frameOptions.setStrict(true);
|
||||
frame.dragAndDrop(selector, ((LocatorImpl) target).selector, frameOptions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ElementHandle elementHandle(ElementHandleOptions options) {
|
||||
if (options == null) {
|
||||
|
||||
@@ -87,6 +87,7 @@ public class TestPageDrag extends TestBase {
|
||||
assertEquals(true, page.evalOnSelector("#target",
|
||||
"target => target.contains(document.querySelector('#source'))")); // could not find source in target
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAllowSpecifyingThePosition() {
|
||||
page.setContent("<div style='width:100px;height:100px;background:red;' id='red'>\n" +
|
||||
@@ -116,4 +117,11 @@ public class TestPageDrag extends TestBase {
|
||||
Object json = eventsHandle.jsonValue();
|
||||
assertJsonEquals("[{type: \"mousedown\", x: 34, y: 7},{type: \"mouseup\", x: 10, y: 20}]", json);
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldWorkWithLocators() {
|
||||
page.navigate(server.PREFIX + "/drag-n-drop.html");
|
||||
page.locator("#source").dragTo(page.locator("#target"));
|
||||
assertEquals(true, page.evalOnSelector("#target", "target => target.contains(document.querySelector('#source'))"));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
1.18.0-alpha-1637368835000
|
||||
1.18.0-alpha-nov-29-2021
|
||||
|
||||
@@ -270,8 +270,10 @@ class TypeRef extends Element {
|
||||
customTypeNames.put("Page.setInputFiles.files", "FilePayload");
|
||||
customTypeNames.put("FormData.set.value", "FilePayload");
|
||||
|
||||
customTypeNames.put("Locator.dragTo.options.sourcePosition", "Position");
|
||||
customTypeNames.put("Page.dragAndDrop.options.sourcePosition", "Position");
|
||||
customTypeNames.put("Frame.dragAndDrop.options.sourcePosition", "Position");
|
||||
customTypeNames.put("Locator.dragTo.options.targetPosition", "Position");
|
||||
customTypeNames.put("Page.dragAndDrop.options.targetPosition", "Position");
|
||||
customTypeNames.put("Frame.dragAndDrop.options.targetPosition", "Position");
|
||||
}
|
||||
@@ -648,12 +650,12 @@ class Method extends Element {
|
||||
if ("PlaywrightAssertions.assertThat".equals(jsonPath)) {
|
||||
writeJavadoc(params, output, offset);
|
||||
String originalName = jsonElement.getAsJsonObject().get("originalName").getAsString();
|
||||
if ("assertThatPage".equals(originalName)) {
|
||||
if ("expectPage".equals(originalName)) {
|
||||
output.add(offset + "static PageAssertions assertThat(Page page) {");
|
||||
output.add(offset + " return new PageAssertionsImpl(page);");
|
||||
output.add(offset + "}");
|
||||
output.add("");
|
||||
} else if ("assertThatLocator".equals(originalName)) {
|
||||
} else if ("expectLocator".equals(originalName)) {
|
||||
output.add(offset + "static LocatorAssertions assertThat(Locator locator) {");
|
||||
output.add(offset + " return new LocatorAssertionsImpl(locator);");
|
||||
output.add(offset + "}");
|
||||
|
||||
Reference in New Issue
Block a user