Skip to content

Commit 25a0927

Browse files
authored
feat: roll driver, comoute count in util world (#769)
1 parent e9b379f commit 25a0927

File tree

6 files changed

+41
-27
lines changed

6 files changed

+41
-27
lines changed

assertions/src/main/java/com/microsoft/playwright/assertions/APIResponseAssertions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public interface APIResponseAssertions {
4747
*/
4848
APIResponseAssertions not();
4949
/**
50-
* Ensures the response status code is within [200..299) range.
50+
* Ensures the response status code is within [200..299] range.
5151
* <pre>{@code
5252
* assertThat(response).isOK();
5353
* }</pre>

assertions/src/main/java/com/microsoft/playwright/assertions/LocatorAssertions.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ default void isVisible() {
452452
* assertThat(page.locator(".title")).containsText("substring");
453453
* }</pre>
454454
*
455-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
455+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
456456
* <pre>{@code
457457
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
458458
* }</pre>
@@ -469,7 +469,7 @@ default void containsText(String expected) {
469469
* assertThat(page.locator(".title")).containsText("substring");
470470
* }</pre>
471471
*
472-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
472+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
473473
* <pre>{@code
474474
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
475475
* }</pre>
@@ -484,7 +484,7 @@ default void containsText(String expected) {
484484
* assertThat(page.locator(".title")).containsText("substring");
485485
* }</pre>
486486
*
487-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
487+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
488488
* <pre>{@code
489489
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
490490
* }</pre>
@@ -501,7 +501,7 @@ default void containsText(Pattern expected) {
501501
* assertThat(page.locator(".title")).containsText("substring");
502502
* }</pre>
503503
*
504-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
504+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
505505
* <pre>{@code
506506
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
507507
* }</pre>
@@ -516,7 +516,7 @@ default void containsText(Pattern expected) {
516516
* assertThat(page.locator(".title")).containsText("substring");
517517
* }</pre>
518518
*
519-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
519+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
520520
* <pre>{@code
521521
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
522522
* }</pre>
@@ -533,7 +533,7 @@ default void containsText(String[] expected) {
533533
* assertThat(page.locator(".title")).containsText("substring");
534534
* }</pre>
535535
*
536-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
536+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
537537
* <pre>{@code
538538
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
539539
* }</pre>
@@ -548,7 +548,7 @@ default void containsText(String[] expected) {
548548
* assertThat(page.locator(".title")).containsText("substring");
549549
* }</pre>
550550
*
551-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
551+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
552552
* <pre>{@code
553553
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
554554
* }</pre>
@@ -565,7 +565,7 @@ default void containsText(Pattern[] expected) {
565565
* assertThat(page.locator(".title")).containsText("substring");
566566
* }</pre>
567567
*
568-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
568+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
569569
* <pre>{@code
570570
* assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
571571
* }</pre>
@@ -623,7 +623,7 @@ default void hasAttribute(String name, Pattern value) {
623623
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
624624
* }</pre>
625625
*
626-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
626+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
627627
* <pre>{@code
628628
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
629629
* }</pre>
@@ -639,7 +639,7 @@ default void hasClass(String expected) {
639639
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
640640
* }</pre>
641641
*
642-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
642+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
643643
* <pre>{@code
644644
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
645645
* }</pre>
@@ -653,7 +653,7 @@ default void hasClass(String expected) {
653653
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
654654
* }</pre>
655655
*
656-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
656+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
657657
* <pre>{@code
658658
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
659659
* }</pre>
@@ -669,7 +669,7 @@ default void hasClass(Pattern expected) {
669669
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
670670
* }</pre>
671671
*
672-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
672+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
673673
* <pre>{@code
674674
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
675675
* }</pre>
@@ -683,7 +683,7 @@ default void hasClass(Pattern expected) {
683683
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
684684
* }</pre>
685685
*
686-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
686+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
687687
* <pre>{@code
688688
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
689689
* }</pre>
@@ -699,7 +699,7 @@ default void hasClass(String[] expected) {
699699
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
700700
* }</pre>
701701
*
702-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
702+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
703703
* <pre>{@code
704704
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
705705
* }</pre>
@@ -713,7 +713,7 @@ default void hasClass(String[] expected) {
713713
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
714714
* }</pre>
715715
*
716-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
716+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
717717
* <pre>{@code
718718
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
719719
* }</pre>
@@ -729,7 +729,7 @@ default void hasClass(Pattern[] expected) {
729729
* assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
730730
* }</pre>
731731
*
732-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
732+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
733733
* <pre>{@code
734734
* assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
735735
* }</pre>
@@ -872,7 +872,7 @@ default void hasJSProperty(String name, Object value) {
872872
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
873873
* }</pre>
874874
*
875-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
875+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
876876
* <pre>{@code
877877
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
878878
* }</pre>
@@ -889,7 +889,7 @@ default void hasText(String expected) {
889889
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
890890
* }</pre>
891891
*
892-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
892+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
893893
* <pre>{@code
894894
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
895895
* }</pre>
@@ -904,7 +904,7 @@ default void hasText(String expected) {
904904
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
905905
* }</pre>
906906
*
907-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
907+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
908908
* <pre>{@code
909909
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
910910
* }</pre>
@@ -921,7 +921,7 @@ default void hasText(Pattern expected) {
921921
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
922922
* }</pre>
923923
*
924-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
924+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
925925
* <pre>{@code
926926
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
927927
* }</pre>
@@ -936,7 +936,7 @@ default void hasText(Pattern expected) {
936936
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
937937
* }</pre>
938938
*
939-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
939+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
940940
* <pre>{@code
941941
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
942942
* }</pre>
@@ -953,7 +953,7 @@ default void hasText(String[] expected) {
953953
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
954954
* }</pre>
955955
*
956-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
956+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
957957
* <pre>{@code
958958
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
959959
* }</pre>
@@ -968,7 +968,7 @@ default void hasText(String[] expected) {
968968
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
969969
* }</pre>
970970
*
971-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
971+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
972972
* <pre>{@code
973973
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
974974
* }</pre>
@@ -985,7 +985,7 @@ default void hasText(Pattern[] expected) {
985985
* assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
986986
* }</pre>
987987
*
988-
* <p> Note that if array is passed as an expected value, entire lists can be asserted:
988+
* <p> Note that if array is passed as an expected value, entire lists of elements can be asserted:
989989
* <pre>{@code
990990
* assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
991991
* }</pre>

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,4 +823,11 @@ void notIsVisibleFail() {
823823
assertTrue(e.getMessage().contains("Locator expected not to be visible"), e.getMessage());
824824
}
825825
}
826+
827+
@Test
828+
void locatorCountShouldWorkWithDeletedMapInMainWorld() {
829+
page.evaluate("Map = 1");
830+
page.locator("#searchResultTableDiv .x-grid3-row").count();
831+
assertThat(page.locator("#searchResultTableDiv .x-grid3-row")).hasCount(0);
832+
}
826833
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,6 +1017,13 @@ void waitForURLImpl(UrlMatcher matcher, WaitForURLOptions options) {
10171017
waitForNavigationImpl(() -> {}, convertType(options, WaitForNavigationOptions.class), matcher);
10181018
}
10191019

1020+
int queryCount(String selector) {
1021+
JsonObject params = new JsonObject();
1022+
params.addProperty("selector", selector);
1023+
JsonObject result = sendMessage("queryCount", params).getAsJsonObject();
1024+
return result.get("value").getAsInt();
1025+
}
1026+
10201027
protected void handleEvent(String event, JsonObject params) {
10211028
if ("loadstate".equals(event)) {
10221029
JsonElement add = params.get("add");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void click(ClickOptions options) {
9292

9393
@Override
9494
public int count() {
95-
return ((Number) evaluateAll("ee => ee.length")).intValue();
95+
return frame.queryCount(selector);
9696
}
9797

9898
@Override

scripts/CLI_VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.18.0-alpha-1641508844000
1+
1.18.0-alpha-jan-10-2022

0 commit comments

Comments
 (0)