Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update interacting_with_a_page.md #666

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ Notice that in the Playwright example, we are using a different selector than in

> If you're not already familiar with CSS selectors and how to find them, we recommend referring to [this lesson](../../web_scraping_for_beginners/data_extraction/using_devtools.md) in the **Web scraping for beginners** course.

Then, we can type some text into an input field with `page.type()`; passing a CSS selector as the first, and the string to input as the second parameter:
Then, we can type some text into a textarea field with `page.type()`; passing a CSS selector as the first, and the string to textarea as the second parameter (Note that "Search" might differ depending on the default language for Google):

```js
// Type the query into the search box
await page.type('input[title="Search"]', 'hello world');
await page.type('textarea[title="Search"]', 'hello world');
```

Finally, we can press a single key by accessing the `keyboard` property of `page` and calling the `press()` function on it:
Expand Down Expand Up @@ -91,7 +91,7 @@ await page.goto('https://google.com/');
await page.click('button:has-text("I agree")');

// Type the query into the search box
await page.type('input[title="Search"]', 'hello world');
await page.type('textarea[title="Search"]', 'hello world');

// Press enter
await page.keyboard.press('Enter');
Expand All @@ -116,7 +116,7 @@ await page.goto('https://google.com/');
await page.click('button + button');

// Type the query into the search box
await page.type('input[title="Search"]', 'hello world');
await page.type('textarea[title="Search"]', 'hello world');

// Press enter
await page.keyboard.press('Enter');
Expand Down Expand Up @@ -148,7 +148,7 @@ await page.goto('https://google.com/');

await page.click('button:has-text("I agree")');

await page.type('input[title="Search"]', 'hello world');
await page.type('textarea[title="Search"]', 'hello world');

await page.keyboard.press('Enter');

Expand All @@ -174,7 +174,7 @@ await page.goto('https://google.com/');

await page.click('button + button');

await page.type('input[title="Search"]', 'hello world');
await page.type('textarea[title="Search"]', 'hello world');

await page.keyboard.press('Enter');

Expand Down
Loading