Skip to content

Commit 1eb2aa7

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

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

lab4/main_test.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,20 @@ const puppeteer = require('puppeteer');
88
// Navigate the page to a URL
99
await page.goto('https://pptr.dev/');
1010

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
19-
20-
// Close the browser
11+
await page.waitForSelector('.DocSearch-Button');
12+
await page.click('.DocSearch-Button');
13+
14+
await page.waitForSelector('.DocSearch-Form');
15+
await page.keyboard.type('chipi chipi chapa chapa');
16+
17+
await page.waitForSelector('#docsearch-item-5 a[href="/webdriver-bidi/#measuring-progress"]');
18+
await page.click('#docsearch-item-5 a[href="/webdriver-bidi/#measuring-progress"]');
19+
20+
await new Promise(resolve => setTimeout(resolve, 2000));
21+
22+
const fullTitle = await page.title();
23+
const desiredTitle = fullTitle.split(' | ')[0];
24+
console.log(desiredTitle);
25+
2126
await browser.close();
22-
})();
27+
})();

0 commit comments

Comments
 (0)