diff --git a/lab4/main_test.js b/lab4/main_test.js index e37d21a5..942a2140 100644 --- a/lab4/main_test.js +++ b/lab4/main_test.js @@ -8,15 +8,20 @@ const puppeteer = require('puppeteer'); // Navigate the page to a URL await page.goto('https://pptr.dev/'); - // Hints: - // Click search button - // Type into search box - // Wait for search result - // Get the `Docs` result section - // Click on first result in `Docs` section - // Locate the title - // Print the title - - // Close the browser + await page.waitForSelector('.DocSearch-Button'); + await page.click('.DocSearch-Button'); + + await page.waitForSelector('.DocSearch-Form'); + await page.keyboard.type('chipi chipi chapa chapa'); + + await page.waitForSelector('#docsearch-item-5 a[href="/webdriver-bidi/#measuring-progress"]'); + await page.click('#docsearch-item-5 a[href="/webdriver-bidi/#measuring-progress"]'); + + await new Promise(resolve => setTimeout(resolve, 2000)); + + const fullTitle = await page.title(); + const desiredTitle = fullTitle.split(' | ')[0]; + console.log(desiredTitle); + await browser.close(); -})(); \ No newline at end of file +})();