Skip to content

Commit 7b741df

Browse files
authored
Update main_test.js
1 parent 11ffa5d commit 7b741df

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lab4/main_test.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,13 @@ const puppeteer = require('puppeteer');
1717
await page.type('#docsearch-input', 'Experimental WebDriver BiDi support', { delay: 150 });
1818

1919
// Wait for search result and click on the first result
20-
await page.waitForSelector('.DocSearch-Hit-content', { timeout: 60000 });
21-
await page.click('.DocSearch-Hit-content');
20+
await page.waitForSelector('.DocSearch-Hits', { timeout: 60000 });
21+
const hits = await page.$$('.DocSearch-Hit');
22+
if (hits.length > 0) {
23+
await hits[0].click();
24+
} else {
25+
throw new Error('No search results found');
26+
}
2227

2328
// Locate the title
2429
let textSelector = await page.waitForSelector('h1', { timeout: 60000 });

0 commit comments

Comments
 (0)