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

[LAB4] 312555001 #618

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 19 additions & 1 deletion lab4/main_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,31 @@ const puppeteer = require('puppeteer');

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

// Type into search box
const searchBox = '.DocSearch-Input';
await page.waitForSelector(searchBox);

// Wait for search result
await page.type(searchBox, 'chipi chipi chapa chapa' , { delay: 1000 });

// Get the `Docs` result section
const docsSection = '#docsearch-item-5';
await page.waitForSelector(docsSection);

// Click on first result in `Docs` section
await page.click(docsSection);

// Locate the title
const textselector = await page.waitForSelector('.markdown h1');
const title = await page.evaluate(element => element.textContent, textselector);

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

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