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();