Skip to content

Commit

Permalink
feat: lab4
Browse files Browse the repository at this point in the history
  • Loading branch information
AlaRduTP committed Mar 21, 2024
1 parent afcb770 commit 28785dd
Show file tree
Hide file tree
Showing 5 changed files with 1,275 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lab4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Lab4

## Introduction

In this lab, you will write tests in `main_test.js`. You can learn how to use [Puppeteer](https://pptr.dev/) to tests a web UI.

## Preparation (Important!!!)

1. Sync fork your branch (e.g., `SQLab:311XXXXXX`)
2. `git checkout -b lab4` (**NOT** your student ID !!!)

## Requirement

1. (100%) Goto https://pptr.dev/, type `chipi chipi chapa chapa` into the search box, click on **1st** result in the **Docs** section, and print the title.

For the detailed steps and hints, please check the slide of this lab.

You can run `validate.sh` in your local to test if you satisfy the requirements.

Please note that you must not alter files other than `main_test.js`. You will get 0 points if

1. you modify other files to achieve requirements.
2. you can't pass all CI on your PR.

## Submission

You need to open a pull request to your branch (e.g. 311XXXXXX, your student number) and contain the code that satisfies the abovementioned requirements.

Moreover, please submit the URL of your PR to E3. Your submission will only be accepted when you present at both places.
22 changes: 22 additions & 0 deletions lab4/main_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const puppeteer = require('puppeteer');

(async () => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch();
const page = await browser.newPage();

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

0 comments on commit 28785dd

Please sign in to comment.