From e3ac7ffe26967c1b2121926f1c8ee77c7d9458d8 Mon Sep 17 00:00:00 2001
From: chyang <chyang.be10@nycu.edu.tw>
Date: Thu, 3 Apr 2025 12:52:14 +0800
Subject: [PATCH] feat: lab4

---
 lab4/main_test.js | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lab4/main_test.js b/lab4/main_test.js
index e37d21a..841ad8f 100644
--- a/lab4/main_test.js
+++ b/lab4/main_test.js
@@ -10,12 +10,24 @@ const puppeteer = require('puppeteer');
 
     // Hints:
     // Click search button
+    await page.waitForSelector('.DocSearch-Button');
+    await page.click('.DocSearch-Button');
+
     // Type into search box
+    await page.locator('#docsearch-input').fill('andy popoo');
+
     // Wait for search result
     // Get the `Docs` result section
     // Click on first result in `Docs` section
+    await page.locator('#docsearch-hits1-item-4 > a > div').click();
+
     // Locate the title
     // Print the title
+    await page.waitForSelector('h1');
+    const title = await page.$eval('h1', (element) => element.textContent);
+
+    // Print the title
+    console.log(title);
 
     // Close the browser
     await browser.close();