Skip to content

Commit e5e3c94

Browse files
authored
Update main_test.js
1 parent b88ef9e commit e5e3c94

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

lab4/main_test.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,37 @@
11
const puppeteer = require('puppeteer');
22

33
(async () => {
4+
45
// Launch the browser and open a new blank page
56
const browser = await puppeteer.launch();
67
const page = await browser.newPage();
78

89
// Navigate the page to a URL
910
await page.goto('https://pptr.dev/');
1011

11-
// Hints:
1212
// Click search button
13+
await page.click('button.DocSearch.DocSearch-Button');
14+
1315
// Type into search box
16+
await page.waitForSelector('#docsearch-input');
17+
1418
// Wait for search result
19+
await page.type('#docsearch-input', 'chipi chipi chapa chapa', { delay: 150 });
20+
1521
// Get the `Docs` result section
22+
await page.waitForSelector('#docsearch-item-5');
23+
1624
// Click on first result in `Docs` section
25+
await page.click('#docsearch-item-5');
26+
1727
// Locate the title
28+
let textSelector = await page.waitForSelector('h1');
29+
let title = await textSelector.evaluate(element => element.textContent);
30+
1831
// Print the title
32+
console.log(title);
33+
1934

2035
// Close the browser
2136
await browser.close();
22-
})();
37+
})();

0 commit comments

Comments
 (0)