diff --git a/lab4/main_test.js b/lab4/main_test.js index e37d21a..2541498 100644 --- a/lab4/main_test.js +++ b/lab4/main_test.js @@ -8,15 +8,24 @@ const puppeteer = require('puppeteer'); // Navigate the page to a URL await page.goto('https://pptr.dev/'); - // 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(); })(); \ No newline at end of file