Skip to content

Commit

Permalink
Merge pull request #363 from Sharkkcode/lab4
Browse files Browse the repository at this point in the history
[LAB4] a121100
  • Loading branch information
AlaRduTP authored Apr 9, 2024
2 parents 9daddf1 + a1eb482 commit a996b7c
Showing 1 changed file with 26 additions and 16 deletions.
42 changes: 26 additions & 16 deletions lab4/main_test.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
const puppeteer = require('puppeteer');
const puppeteer = require("puppeteer");

(async () => {
// Launch the browser and open a new blank page
// open website
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("https://pptr.dev/");

// click search box
const searchArea = ".DocSearch-Button"
await page.waitForSelector(searchArea);
await page.click(searchArea);

// type and srearch
const searchBox = ".DocSearch-Input";
const searchText = "chipi chipi chapa chapa";
await page.waitForSelector(searchBox);
await page.type(searchBox, searchText, { delay: 1000 });

// click search item
const docsSearchItem = "#docsearch-item-5"
await page.waitForSelector(docsSearchItem);
await page.click(docsSearchItem);

// select and print text
const title = await page.waitForSelector('.markdown h1');
const titleText = await page.evaluate(x => x.textContent, title);
console.log(titleText);

// 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
// close browser
await browser.close();
})();
})();

0 comments on commit a996b7c

Please sign in to comment.