Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(java): assertion docs fixes (#10144)

Yury Semikhatskyac25a67140fe
diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.md
index cec73cc9bb..eda9a2f39f 100644
--- a/docs/src/api/class-locatorassertions.md
+++ b/docs/src/api/class-locatorassertions.md
@@ -14,7 +14,7 @@ assertThat(page.locator(".title")).containsText("substring");
Note that if array is passed as an expected value, entire lists can be asserted:
```java
-assertThat(page.locator("list > .list-item")).containsText(Arrays.asList("Text 1", "Text 4", "Text 5"));
+assertThat(page.locator("list > .list-item")).containsText(new String[] {"Text 1", "Text 4", "Text 5"});
```
### param: LocatorAssertions.containsText.expected
@@ -60,7 +60,7 @@ assertThat(page.locator("#component")).hasClass(Pattern.compile("selected"));
Note that if array is passed as an expected value, entire lists can be asserted:
```java
-assertThat(page.locator("list > .component")).hasClass(Arrays.asList("component", "component selected", "component"));
+assertThat(page.locator("list > .component")).hasClass(new String[] {"component", "component selected", "component"});
```
### param: LocatorAssertions.hasClass.expected
@@ -145,14 +145,14 @@ Property value.
Ensures the [Locator] points to an element with the given text. You can use regular expressions for the value as well.
```java
-assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, Test User"));
+assertThat(page.locator(".title")).hasText("Welcome, Test User");
assertThat(page.locator(".title")).hasText(Pattern.compile("Welcome, .*"));
```
Note that if array is passed as an expected value, entire lists can be asserted:
```java
-assertThat(page.locator("list > .component")).hasText(Arrays.asList("Text 1", "Text 2", "Text 3"));
+assertThat(page.locator("list > .component")).hasText(new String[] {"Text 1", "Text 2", "Text 3"});
```
### param: LocatorAssertions.hasText.expected
diff --git a/docs/src/api/class-pageassertions.md b/docs/src/api/class-pageassertions.md
index 2edef1818f..6a56183034 100644
--- a/docs/src/api/class-pageassertions.md
+++ b/docs/src/api/class-pageassertions.md
@@ -23,7 +23,7 @@ Expected title or RegExp.
Ensures the page is navigated to the given URL.
```java
-assertThat(page).hasURL('.com');
+assertThat(page).hasURL(".com");
```
### param: PageAssertions.hasURL.urlOrRegExp
@@ -39,5 +39,5 @@ Expected substring or RegExp.
Makes the assertion check for the opposite condition. For example, this code tests that the page URL doesn't contain `"error"`:
```java
-assertThat(page).not().hasURL('error');
+assertThat(page).not().hasURL("error");
```