This repository contains a simple example demonstrating the usage of Playwright, a powerful library for browser automation. The example showcases Playwright's project creation and its dockernization.
Make sure you have the following installed on your system:
- Node.js (version 14 or later)
- npm (comes with Node.js)
Follow these steps to set up and run the example:
First, create a new Playwright project by running the following command:
npm init playwright@latest
This command will set up a new Playwright project and install all necessary dependencies.
To execute the tests you have created, use the following command:
npx playwright test
This command will run all the tests in your project.
After running your tests, you can view the test report by executing:
npx playwright show-report
This command will display a detailed report of your test results, including any passed or failed tests.
FROM mcr.microsoft.com/playwright:v1.48.2
WORKDIR /app
COPY . /app
RUN npm install
CMD [ "npx", "playwright", "test" ]
docker build -t playwright-for-dummies .
docker run --rm -it --shm-size=2gb playwright-for-dummies
This command will display a detailed report of your test results, including any passed or failed tests.
To upload your Docker image to Docker Hub, follow these steps:
-
Create a Docker Hub Account
- If you don’t already have a Docker Hub account, sign up at Docker Hub.
-
Log in to Docker Hub
- In your terminal, log in to your Docker Hub account:
docker login
- In your terminal, log in to your Docker Hub account:
-
Tag and Push the Docker Image
- Before pushing the image, tag it with your Docker Hub username and repository name.
docker tag playwright-for-dummies your-username/conversao-distancia
- To push the image to Docker Hub, simply run:
docker push your-username/playwright-for-dummies
The previous command will build and push an image without any specific version, tagging it as
latest
. It is a best practice to use an specific version instead of only 'latest' in order to avoid break changes in the future. So it is advisable to have both uploaded to the Docker Registry, the current version as well as the latest. To do this perform the commands below:docker tag your-username/playwright-for-dummies:latest your-username/playwright-for-dummies:v1 docker push your-username/playwright-for-dummies:v1
- Before pushing the image, tag it with your Docker Hub username and repository name.
-
Verify the Upload
- Go to your Docker Hub account and check if the image appears in your repositories.