diff --git a/docs/src/actionability.md b/docs/src/actionability.md
index 07d8d7d118..d41141de28 100644
--- a/docs/src/actionability.md
+++ b/docs/src/actionability.md
@@ -65,6 +65,12 @@ actionable state:
- [`method: Page.isEnabled`]
- [`method: Page.isHidden`]
- [`method: Page.isVisible`]
+- [`method: Locator.isChecked`]
+- [`method: Locator.isDisabled`]
+- [`method: Locator.isEditable`]
+- [`method: Locator.isEnabled`]
+- [`method: Locator.isHidden`]
+- [`method: Locator.isVisible`]
diff --git a/docs/src/api-testing-csharp.md b/docs/src/api-testing-csharp.md
index a316426568..52fa1f3e83 100644
--- a/docs/src/api-testing-csharp.md
+++ b/docs/src/api-testing-csharp.md
@@ -368,10 +368,10 @@ it was created:
public async Task LastCreatedIssueShouldBeOnTheServer()
{
await Page.GotoAsync("https://github.com/" + USER + "/" + REPO + "/issues");
- await Page.ClickAsync("text=New Issue");
- await Page.FillAsync("[aria-label='Title']", "Bug report 1");
- await Page.FillAsync("[aria-label='Comment body']", "Bug description");
- await Page.ClickAsync("text=Submit new issue");
+ await Page.Locator("text=New Issue").ClickAsync();
+ await Page.Locator("[aria-label='Title']").FillAsync("Bug report 1");
+ await Page.Locator("[aria-label='Comment body']").FillAsync("Bug description");
+ await Page.Locator("text=Submit new issue").ClickAsync();
String issueId = Page.Url.Substring(Page.Url.LastIndexOf('/'));
var newIssue = await Request.GetAsync("https://github.com/" + USER + "/" + REPO + "/issues/" + issueId);
diff --git a/docs/src/api-testing-java.md b/docs/src/api-testing-java.md
index ad1598cff4..792fa11e58 100644
--- a/docs/src/api-testing-java.md
+++ b/docs/src/api-testing-java.md
@@ -403,10 +403,10 @@ it was created:
@Test
void lastCreatedIssueShouldBeOnTheServer() {
page.navigate("https://github.com/" + USER + "/" + REPO + "/issues");
- page.click("text=New Issue");
- page.fill("[aria-label='Title']", "Bug report 1");
- page.fill("[aria-label='Comment body']", "Bug description");
- page.click("text=Submit new issue");
+ page.locator("text=New Issue").click();
+ page.locator("[aria-label='Title']").fill("Bug report 1");
+ page.locator("[aria-label='Comment body']").fill("Bug description");
+ page.locator("text=Submit new issue").click();
String issueId = page.url().substring(page.url().lastIndexOf('/'));
APIResponse newIssue = request.get("https://github.com/" + USER + "/" + REPO + "/issues/" + issueId);
diff --git a/docs/src/api-testing-python.md b/docs/src/api-testing-python.md
index 26d8c70609..af29aac2bf 100644
--- a/docs/src/api-testing-python.md
+++ b/docs/src/api-testing-python.md
@@ -254,10 +254,10 @@ it was created:
```python
def test_last_created_issue_should_be_on_the_server(api_request_context: APIRequestContext, page: Page) -> None:
page.goto(f"https://github.com/{GITHUB_USER}/{GITHUB_REPO}/issues")
- page.click("text=New issue")
- page.fill("[aria-label='Title']", "Bug report 1")
- page.fill("[aria-label='Comment body']", "Bug description")
- page.click("text=Submit new issue")
+ page.locator("text=New issue").click()
+ page.locator("[aria-label='Title']").fill("Bug report 1")
+ page.locator("[aria-label='Comment body']").fill("Bug description")
+ page.locator("text=Submit new issue").click()
issue_id = page.url.split("/")[-1]
new_issue = api_request_context.get(f"https://github.com/{GITHUB_USER}/{GITHUB_REPO}/issues/{issue_id}")
diff --git a/docs/src/api/class-browsertype.md b/docs/src/api/class-browsertype.md
index 2daa4986f1..486390830d 100644
--- a/docs/src/api/class-browsertype.md
+++ b/docs/src/api/class-browsertype.md
@@ -78,7 +78,7 @@ class BrowserTypeExamples
var chromium = playwright.Chromium;
var browser = await chromium.LaunchAsync();
var page = await browser.NewPageAsync();
- await page.GoToAsync("https://www.bing.com");
+ await page.GotoAsync("https://www.bing.com");
// other actions
await browser.CloseAsync();
}
diff --git a/docs/src/auth.md b/docs/src/auth.md
index a896415a2e..c454fce971 100644
--- a/docs/src/auth.md
+++ b/docs/src/auth.md
@@ -29,10 +29,10 @@ const page = await context.newPage();
await page.goto('https://github.com/login');
// Interact with login form
-await page.click('text=Login');
-await page.fill('input[name="login"]', USERNAME);
-await page.fill('input[name="password"]', PASSWORD);
-await page.click('text=Submit');
+await page.locator('text=Login').click();
+await page.locator('input[name="login"]').fill(USERNAME);
+await page.locator('input[name="password"]').fill(PASSWORD);
+await page.locator('text=Submit').click();
// Verify app is logged in
```
@@ -40,10 +40,10 @@ await page.click('text=Submit');
Page page = context.newPage();
page.navigate("https://github.com/login");
// Interact with login form
-page.click("text=Login");
-page.fill("input[name='login']", USERNAME);
-page.fill("input[name='password']", PASSWORD);
-page.click("text=Submit");
+page.locator("text=Login").click();
+page.locator("input[name='login']").fill(USERNAME);
+page.locator("input[name='password']").fill(PASSWORD);
+page.locator("text=Submit").click();
// Verify app is logged in
```
@@ -52,10 +52,10 @@ page = await context.new_page()
await page.goto('https://github.com/login')
# Interact with login form
-await page.click('text=Login')
-await page.fill('input[name="login"]', USERNAME)
-await page.fill('input[name="password"]', PASSWORD)
-await page.click('text=Submit')
+await page.locator('text=Login').click()
+await page.locator('input[name="login"]').fill(USERNAME)
+await page.locator('input[name="password"]').fill(PASSWORD)
+await page.locator('text=Submit').click()
# Verify app is logged in
```
@@ -64,21 +64,21 @@ page = context.new_page()
page.goto('https://github.com/login')
# Interact with login form
-page.click('text=Login')
-page.fill('input[name="login"]', USERNAME)
-page.fill('input[name="password"]', PASSWORD)
-page.click('text=Submit')
+page.locator('text=Login').click()
+page.locator('input[name="login"]').fill(USERNAME)
+page.locator('input[name="password"]').fill(PASSWORD)
+page.locator('text=Submit').click()
# Verify app is logged in
```
```csharp
var page = await context.NewPageAsync();
-await page.NavigateAsync("https://github.com/login");
+await page.GotoAsync("https://github.com/login");
// Interact with login form
-await page.ClickAsync("text=Login");
-await page.FillAsync("input[name='login']", USERNAME);
-await page.FillAsync("input[name='password']", PASSWORD);
-await page.ClickAsync("text=Submit");
+await page.Locator("text=Login").ClickAsync();
+await page.Locator("input[name='login']").FillAsync(USERNAME);
+await page.Locator("input[name='password']").FillAsync(PASSWORD);
+await page.Locator("text=Submit").ClickAsync();
// Verify app is logged in
```
diff --git a/docs/src/dialogs.md b/docs/src/dialogs.md
index 3aed7f6eb8..56eaa2eeec 100644
--- a/docs/src/dialogs.md
+++ b/docs/src/dialogs.md
@@ -13,27 +13,27 @@ By default, dialogs are auto-dismissed by Playwright, so you don't have to handl
```js
page.on('dialog', dialog => dialog.accept());
-await page.click('button');
+await page.locator('button').click();
```
```java
page.onDialog(dialog -> dialog.accept());
-page.click("button");
+page.locator("button").click();
```
```python async
page.on("dialog", lambda dialog: dialog.accept())
-await page.click("button")
+await page.locator("button".click())
```
```python sync
page.on("dialog", lambda dialog: dialog.accept())
-page.click("button")
+page.locator("button").click()
```
```csharp
page.Dialog += (_, dialog) => dialog.AcceptAsync();
-await page.ClickAsync("button");
+await page.Locator("button").ClickAsync();
```
:::note
@@ -48,27 +48,27 @@ WRONG!
```js
page.on('dialog', dialog => console.log(dialog.message()));
-await page.click('button'); // Will hang here
+await page.locator('button').click(); // Will hang here
```
```java
page.onDialog(dialog -> System.out.println(dialog.message()));
-page.click("button"); // Will hang here
+page.locator("button").click(); // Will hang here
```
```python async
page.on("dialog", lambda dialog: print(dialog.message))
-await page.click("button") # Will hang here
+await page.locator("button").click() # Will hang here
```
```python sync
page.on("dialog", lambda dialog: print(dialog.message))
-page.click("button") # Will hang here
+page.locator("button").click() # Will hang here
```
```csharp
page.Dialog += (_, dialog) => Console.WriteLine(dialog.Message);
-await page.ClickAsync("button"); // Will hang here
+await page.Locator("button").ClickAsync(); // Will hang here
```
:::note
@@ -92,7 +92,7 @@ page.on('dialog', async dialog => {
assert(dialog.type() === 'beforeunload');
await dialog.dismiss();
});
-await page.close({runBeforeUnload: true});
+await page.close({ runBeforeUnload: true });
```
```java
diff --git a/docs/src/downloads.md b/docs/src/downloads.md
index 88e4224a42..a41890dcb1 100644
--- a/docs/src/downloads.md
+++ b/docs/src/downloads.md
@@ -34,7 +34,7 @@ const path = await download.path();
// Wait for the download to start
Download download = page.waitForDownload(() -> {
// Perform the action that initiates download
- page.click("button#delayed-download");
+ page.locator("button#delayed-download").click();
});
// Wait for the download process to complete
Path path = download.path();
@@ -44,7 +44,7 @@ Path path = download.path();
# Start waiting for the download
async with page.expect_download() as download_info:
# Perform the action that initiates download
- await page.click("button#delayed-download")
+ await page.locator("button#delayed-download").click()
download = await download_info.value
# Wait for the download process to complete
path = await download.path()
@@ -54,7 +54,7 @@ path = await download.path()
# Start waiting for the download
with page.expect_download() as download_info:
# Perform the action that initiates download
- page.click("button#delayed-download")
+ page.locator("button#delayed-download").click()
download = download_info.value
# Wait for the download process to complete
path = download.path()
@@ -64,7 +64,7 @@ path = download.path()
// Start the task of waiting for the download
var waitForDownloadTask = page.WaitForDownloadAsync();
// Perform the action that initiates download
-await page.ClickAsync("#downloadButton");
+await page.Locator("#downloadButton").ClickAsync();
// Wait for the download process to complete
var download = await waitForDownloadTask;
var path = await download.PathAsync();
diff --git a/docs/src/input.md b/docs/src/input.md
index 0fc69c23d0..f58f77aa21 100644
--- a/docs/src/input.md
+++ b/docs/src/input.md
@@ -11,94 +11,94 @@ This is the easiest way to fill out the form fields. It focuses the element and
```js
// Text input
-await page.fill('#name', 'Peter');
+await page.locator('#name').fill('Peter');
// Date input
-await page.fill('#date', '2020-02-02');
+await page.locator('#date').fill('2020-02-02');
// Time input
-await page.fill('#time', '13:15');
+await page.locator('#time').fill('13:15');
// Local datetime input
-await page.fill('#local', '2020-03-02T05:15');
+await page.locator('#local').fill('2020-03-02T05:15');
// Input through label
-await page.fill('text=First Name', 'Peter');
+await page.locator('text=First Name').fill('Peter');
```
```java
// Text input
-page.fill("#name", "Peter");
+page.locator("#name").fill("Peter");
// Date input
-page.fill("#date", "2020-02-02");
+page.locator("#date").fill("2020-02-02");
// Time input
-page.fill("#time", "13-15");
+page.locator("#time").fill("13-15");
// Local datetime input
-page.fill("#local", "2020-03-02T05:15");
+page.locator("#local").fill("2020-03-02T05:15");
// Input through label
-page.fill("text=First Name", "Peter");
+page.locator("text=First Name").fill("Peter");
```
```python async
# Text input
-await page.fill('#name', 'Peter')
+await page.locator('#name').fill('Peter')
# Date input
-await page.fill('#date', '2020-02-02')
+await page.locator('#date').fill('2020-02-02')
# Time input
-await page.fill('#time', '13:15')
+await page.locator('#time').fill('13:15')
# Local datetime input
-await page.fill('#local', '2020-03-02T05:15')
+await page.locator('#local').fill('2020-03-02T05:15')
# Input through label
-await page.fill('text=First Name', 'Peter')
+await page.locator('text=First Name').fill('Peter')
```
```python sync
# Text input
-page.fill('#name', 'Peter')
+page.locator('#name').fill('Peter')
# Date input
-page.fill('#date', '2020-02-02')
+page.locator('#date').fill('2020-02-02')
# Time input
-page.fill('#time', '13:15')
+page.locator('#time').fill('13:15')
# Local datetime input
-page.fill('#local', '2020-03-02T05:15')
+page.locator('#local').fill('2020-03-02T05:15')
# Input through label
-page.fill('text=First Name', 'Peter')
+page.locator('text=First Name').fill('Peter')
```
```csharp
// Text input
-await page.FillAsync("#name", "Peter");
+await page.Locator("#name").FillAsync("Peter");
// Date input
-await page.FillAsync("#date", "2020-02-02");
+await page.Locator("#date").FillAsync("2020-02-02");
// Time input
-await page.FillAsync("#time", "13-15");
+await page.Locator("#time").FillAsync("13-15");
// Local datetime input
-await page.FillAsync("#local", "2020-03-02T05:15");
+await page.Locator("#local").FillAsync("2020-03-02T05:15");
// Input through label
-await page.FillAsync("text=First Name", "Peter");
+await page.Locator("text=First Name").FillAsync("Peter");
```
### API reference
+- [`method: Locator.fill`]
- [`method: Page.fill`]
- [`method: Frame.fill`]
-- [`method: ElementHandle.fill`]
@@ -108,170 +108,150 @@ This is the easiest way to check and uncheck a checkbox or a radio button. This
```js
// Check the checkbox
-await page.check('#agree');
+await page.locator('#agree').check();
// Assert the checked state
-expect(await page.isChecked('#agree')).toBeTruthy()
+expect(await page.locator('#agree').isChecked()).toBeTruthy()
// Uncheck by input