Skip to content

[LAB4] 313551054 #307

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

Merged
merged 1 commit into from
Jun 5, 2025
Merged
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: 15 additions & 0 deletions lab4/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,27 @@ const puppeteer = require('puppeteer');

// Hints:
// Click search button
await new Promise(resolve => setTimeout(resolve, 3000));
await page.locator('.DocSearch-Button-Placeholder').click();

// Type into search box
await page.waitForSelector('.DocSearch-Input');
await page.type('.DocSearch-Input','andy popoo');

// Wait for search result
// Get the `Docs` result section
// Click on first result in `Docs` section
await new Promise(resolve => setTimeout(resolve, 3000));
const element = await page.waitForSelector('#docsearch-hits1-item-4');
await element.click();

// Locate the title
await new Promise(resolve => setTimeout(resolve, 3000));
const textSelector = await page.waitForSelector('header h1');

// Print the title
const fullTitle = await textSelector?.evaluate(el => el.textContent);
console.log(fullTitle);

// Close the browser
await browser.close();
Expand Down
Loading