Skip to content

Commit 1f7fdd2

Browse files
committed
clean code
1 parent fde538d commit 1f7fdd2

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

lab4/main_test.js

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const puppeteer = require('puppeteer');
1313
await page.waitForSelector('#__docusaurus > nav > div.navbar__inner > div.navbar__items.navbar__items--right > div.navbarSearchContainer_IP3a > button > span.DocSearch-Button-Container > svg');
1414
await page.click('#__docusaurus > nav > div.navbar__inner > div.navbar__items.navbar__items--right > div.navbarSearchContainer_IP3a > button > span.DocSearch-Button-Container > svg');
1515
// Type into search box
16-
// await page.type('.navbarSearchContainer_IP3a input', 'chipi chipi chapa chapa');
1716
await page.waitForSelector('.DocSearch-Input');
1817
await page.type('.DocSearch-Input', 'andy popoo' , { delay: 100 });
1918

@@ -26,24 +25,11 @@ const puppeteer = require('puppeteer');
2625
const docsSection = await page.$$('.DocSearch-Hit');
2726
const limit = 5; // limit the number of results to show
2827
const visibleDocsSection = docsSection.slice(0, limit); // get the first 5 results
29-
// if (visibleDocsSection.length > 0) {
30-
// for (let i = 0; i < visibleDocsSection.length; i++) {
31-
// const title = await visibleDocsSection[i].$eval('.DocSearch-Hit-title', el => el.innerText);
32-
// // console.log(`搜尋結果 ${i + 1}: ${title}`);
33-
// }
34-
35-
// // Click the first result
36-
// const clickedTitle = await visibleDocsSection[0].$eval('.DocSearch-Hit-title', el => el.innerText);
37-
// // console.log(`即將點擊的搜尋結果: ${clickedTitle}`);
38-
39-
// await visibleDocsSection[4].click();
40-
// } else {
41-
// console.log('Results not found!');
42-
// }
28+
4329
if (visibleDocsSection.length > 0) {
44-
await visibleDocsSection[4].click(); // 點擊第一個搜尋結果
30+
await visibleDocsSection[4].click();
4531
} else {
46-
console.log('搜尋結果沒有找到!');
32+
console.log('No results found');
4733
}
4834
// Locate the title
4935
// Print the title

0 commit comments

Comments
 (0)