Skip to content

Commit 4ad0e65

Browse files
committed
assert
1 parent 9048a0f commit 4ad0e65

File tree

6 files changed

+50
-58
lines changed

6 files changed

+50
-58
lines changed

playwright/src/main/java/com/microsoft/playwright/impl/LocatorAssertionsImpl.java

Lines changed: 42 additions & 43 deletions
Large diffs are not rendered by default.

playwright/src/main/java/com/microsoft/playwright/impl/LocatorImpl.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ private LocatorImpl(FrameImpl frame, String selector, LocatorOptions options, Bo
6767
this.selector = selector;
6868
}
6969

70-
private static String escapeWithQuotes(String text) {
71-
return gson().toJson(text);
72-
}
73-
7470
private <R, O> R withElement(BiFunction<ElementHandle, O, R> callback, O options, String title) {
7571
return frame.withTitle(title, () -> {
7672
ElementHandleOptions handleOptions = convertType(options, ElementHandleOptions.class);

playwright/src/main/java/com/microsoft/playwright/impl/PageAssertionsImpl.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import java.util.regex.Pattern;
2323

24-
import static com.microsoft.playwright.impl.LocatorAssertionsImpl.shouldIgnoreCase;
2524
import static com.microsoft.playwright.impl.UrlMatcher.resolveUrl;
2625
import static com.microsoft.playwright.impl.Utils.convertType;
2726

@@ -42,13 +41,13 @@ public void hasTitle(String title, HasTitleOptions options) {
4241
ExpectedTextValue expected = new ExpectedTextValue();
4342
expected.string = title;
4443
expected.normalizeWhiteSpace = true;
45-
expectImpl("to.have.title", expected, title, "Page title expected to be", convertType(options, FrameExpectOptions.class), "Expect \"hasTitle\"");
44+
expectImpl("to.have.title", expected, title, "Page title expected to be", convertType(options, FrameExpectOptions.class), "Assert \"hasTitle\"");
4645
}
4746

4847
@Override
4948
public void hasTitle(Pattern pattern, HasTitleOptions options) {
5049
ExpectedTextValue expected = expectedRegex(pattern);
51-
expectImpl("to.have.title", expected, pattern, "Page title expected to match regex", convertType(options, FrameExpectOptions.class), "Expect \"hasTitle\"");
50+
expectImpl("to.have.title", expected, pattern, "Page title expected to match regex", convertType(options, FrameExpectOptions.class), "Assert \"hasTitle\"");
5251
}
5352

5453
@Override
@@ -59,13 +58,13 @@ public void hasURL(String url, HasURLOptions options) {
5958
}
6059
expected.string = url;
6160
expected.ignoreCase = shouldIgnoreCase(options);
62-
expectImpl("to.have.url", expected, url, "Page URL expected to be", convertType(options, FrameExpectOptions.class), "Expect \"hasURL\"");
61+
expectImpl("to.have.url", expected, url, "Page URL expected to be", convertType(options, FrameExpectOptions.class), "Assert \"hasURL\"");
6362
}
6463

6564
@Override
6665
public void hasURL(Pattern pattern, HasURLOptions options) {
6766
ExpectedTextValue expected = expectedRegex(pattern);
68-
expectImpl("to.have.url", expected, pattern, "Page URL expected to match regex", convertType(options, FrameExpectOptions.class), "Expect \"hasURL\"");
67+
expectImpl("to.have.url", expected, pattern, "Page URL expected to match regex", convertType(options, FrameExpectOptions.class), "Assert \"hasURL\"");
6968
}
7069

7170
@Override

playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,7 @@ void defaultTimeoutHasTextFail() {
10701070
Locator locator = page.locator("div");
10711071
PlaywrightAssertions.setDefaultAssertionTimeout(1000);
10721072
AssertionFailedError exception = assertThrows(AssertionFailedError.class, () -> assertThat(locator).hasText("foo"));
1073-
assertTrue(exception.getMessage().contains("Expect \"hasText\" with timeout 1000ms"), exception.getMessage());
1073+
assertTrue(exception.getMessage().contains("Assert \"hasText\" with timeout 1000ms"), exception.getMessage());
10741074
// Restore default.
10751075
PlaywrightAssertions.setDefaultAssertionTimeout(5_000);
10761076
}
@@ -1119,7 +1119,7 @@ void containsClassFail() {
11191119
AssertionFailedError e = assertThrows(AssertionFailedError.class, () -> {
11201120
assertThat(page.locator("div")).containsClass("does-not-exist", new ContainsClassOptions().setTimeout(1000));
11211121
});
1122-
assertTrue(e.getMessage().contains("Expect \"containsClass\" with timeout 1000ms"), e.getMessage());
1122+
assertTrue(e.getMessage().contains("Assert \"containsClass\" with timeout 1000ms"), e.getMessage());
11231123
}
11241124

11251125
@Test
@@ -1137,6 +1137,6 @@ void containsClassFailWithArray() {
11371137
AssertionFailedError e = assertThrows(AssertionFailedError.class, () -> {
11381138
assertThat(page.locator("div")).containsClass(asList("foo", "bar", "baz"), new ContainsClassOptions().setTimeout(1000));
11391139
});
1140-
assertTrue(e.getMessage().contains("Expect \"containsClass\" with timeout 1000ms"), e.getMessage());
1140+
assertTrue(e.getMessage().contains("Assert \"containsClass\" with timeout 1000ms"), e.getMessage());
11411141
}
11421142
}

playwright/src/test/java/com/microsoft/playwright/TestLocatorAssertions2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,6 @@ void toBeEditableFailWithIndeterminateTrue() {
218218
AssertionFailedError e = assertThrows(AssertionFailedError.class, () ->
219219
assertThat(locator).isChecked(new LocatorAssertions.IsCheckedOptions().setIndeterminate(true).setTimeout(1000)));
220220
// TODO: should be "assertThat().isChecked() with timeout 1000ms"
221-
assertTrue(e.getMessage().contains("Expect \"isChecked\" with timeout 1000ms"), e.getMessage());
221+
assertTrue(e.getMessage().contains("Assert \"isChecked\" with timeout 1000ms"), e.getMessage());
222222
}
223223
}

playwright/src/test/java/com/microsoft/playwright/TestPlaywrightCreate.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,10 @@
1717
package com.microsoft.playwright;
1818

1919
import com.microsoft.playwright.impl.PlaywrightImpl;
20-
import com.microsoft.playwright.impl.driver.Driver;
2120
import org.junit.jupiter.api.Test;
2221
import org.junit.jupiter.api.io.TempDir;
2322

2423
import java.io.IOException;
25-
import java.lang.reflect.Field;
2624
import java.nio.file.DirectoryStream;
2725
import java.nio.file.Files;
2826
import java.nio.file.Path;

0 commit comments

Comments
 (0)