Skip to content

Commit 08f0dad

Browse files
authored
Merge branch '512559005' into lab7
2 parents db4cec9 + a83cde5 commit 08f0dad

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

lab4/main_test.js

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

33
(async () => {
4-
// Launch the browser and open a new blank page
54
const browser = await puppeteer.launch();
65
const page = await browser.newPage();
7-
8-
// Navigate the page to a URL
96
await page.goto('https://pptr.dev/');
107

11-
// Hints:
12-
// Click search button
13-
// Type into search box
14-
// Wait for search result
15-
// Get the `Docs` result section
16-
// Click on first result in `Docs` section
17-
// Locate the title
18-
// Print the title
8+
await page.setViewport({width: 1080, height: 1024});
9+
10+
await page.waitForSelector('.DocSearch-Button');
11+
await page.click('.DocSearch-Button');
12+
13+
await page.waitForSelector('#docsearch-input');
14+
await page.type('#docsearch-input',"chipi chipi chapa chapa")
15+
16+
await new Promise((resolve)=>{
17+
setTimeout((resolve),3000)
18+
})
19+
20+
await page.waitForSelector('#docsearch-item-5 a');
21+
await page.click('#docsearch-item-5 a');
22+
23+
24+
await new Promise((resolve)=>{
25+
setTimeout((resolve),3000)
26+
})
1927

20-
// Close the browser
28+
const element = await page.waitForSelector('h1');
29+
const title = await element.evaluate((ele)=>{
30+
return ele.textContent
31+
})
32+
console.log(title);
2133
await browser.close();
22-
})();
34+
})();

0 commit comments

Comments
 (0)