Skip to content

[LAB4] 313551109 #312

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

Open
wants to merge 1 commit into
base: 313551109
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
15 changes: 12 additions & 3 deletions lab4/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,24 @@ const puppeteer = require('puppeteer');
// Navigate the page to a URL
await page.goto('https://pptr.dev/');

// Hints:
// Click search button
await page.waitForSelector('.DocSearch-Button');
await page.click('.DocSearch-Button');

// Type into search box
await page.locator('#docsearch-input').fill('andy popoo');

// Wait for search result
// Get the `Docs` result section
// Click on first result in `Docs` section
await page.locator('#docsearch-hits1-item-4 > a > div').click();

// Locate the title
// Print the title
await page.waitForSelector('h1');
const title = await page.$eval('h1', (element) => element.textContent);

// Print the title
console.log(title);

// Close the browser
await browser.close();
})();
Loading