Skip to content

Commit 7cd1562

Browse files
authored
Update main_test.js
1 parent 60cf78b commit 7cd1562

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lab4/main_test.js

+6-8
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ const puppeteer = require('puppeteer');
2020
await page.type(searchInputSelector, 'chipi chipi chapa chapa');
2121

2222
// Wait for and click the first search result in the Docs section (obfuscated selector)
23-
const firstResultSelector = '#docsearch-item-5 > a';
24-
await page.waitForSelector(firstResultSelector, { timeout: 3000 });
25-
await page.click(firstResultSelector);
26-
23+
await page.waitForSelector('.DocSearch-Hit-source');
24+
const firstResult = await page.$('.DocSearch-Hit-source', { timeout: 3000 });
25+
await firstResult.click()
2726
// Extract and print the title
28-
const titleSelector = 'h1'; // Maintained clear selector for readability
29-
await page.waitForSelector(titleSelector);
30-
const titleElement = await page.$(titleSelector);
31-
const titleText = await page.evaluate(el => el.textContent, titleElement);
27+
await page.waitForSelector('h1')
28+
const titleElement = await page.$('h1');
29+
const titleText = await page.evaluate(el => el.textContent, titleElement);
3230
console.log(titleText);
3331

3432
// Close the browser

0 commit comments

Comments
 (0)