diff --git a/lab4/main_test.js b/lab4/main_test.js index e37d21a5..3eb54d8e 100644 --- a/lab4/main_test.js +++ b/lab4/main_test.js @@ -10,13 +10,31 @@ const puppeteer = require('puppeteer'); // Hints: // Click search button + const searchButton = '.DocSearch-Button'; + await page.waitForSelector(searchButton); + await page.click(searchButton); + // Type into search box + const searchBox = '.DocSearch-Input'; + await page.waitForSelector(searchBox); + // Wait for search result + await page.type(searchBox, 'chipi chipi chapa chapa' , { delay: 1000 }); + // Get the `Docs` result section + const docsSection = '#docsearch-item-5'; + await page.waitForSelector(docsSection); + // Click on first result in `Docs` section + await page.click(docsSection); + // Locate the title + const textselector = await page.waitForSelector('.markdown h1'); + const title = await page.evaluate(element => element.textContent, textselector); + // Print the title + console.log(title); // Close the browser await browser.close(); -})(); \ No newline at end of file +}) \ No newline at end of file