MuukTest offers integration with Playwright. This tutorial helps us execute our tests locally in your machine with a script that is ready to run, or we can modify it as required.
Note: This tutorial is for Linux based Operating Systems (e.g. MacOS & Ubuntu)
Prerequisites
In this section, we will install the playwright prerequisites. Once you have completed them, you can proceed to set up and install all the necessary libraries to run the script.
List of prerequisites:
- Creating a new folder for the project
- Download key.pub and place it in the folder created in the first step
- Node JS 14.X installation
- Installing gcc/g++/make
- Installing Homebrew (MacOS only)
Create a folder project.
Create a new folder. You can choose any name for it, and it can be located anywhere. In this example, we are naming it 'playwright'
Verify that the folder was created.
Enter your new folder to next continue with the installation.
Download key.pub and place it in the folder created in the first step
Go to MuukTest; in your left-side menu, you will see the Account tab; once you are there, you will see the following screen:
At the top of the screen, the very first option is Profile, you go to key and click on download. Once downloaded, make sure that the downloaded file is in the folder you created during the first step of the prerequisites.
Node.js installation
To ensure you are using the required Node.js version, run the steps below to install it.
- Run the following command to get the required Node.js version, at least version 14.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
- Install Node.js 14.x and npm using the next command.
sudo apt-get install -y nodejs
Installing gcc/g++/make
For Ubuntu or Linux based:
You may also need development tools to build native add-ons. To acquire them, run the following command. If you know that you have them, you can skip this step.
sudo apt-get install gcc g++ make
For MacOS:
For MacOS users, please install XCode in order to get the previously mentioned libraries. You can download XCode directly from the Apple Store.
Download unzip library
When you download the test to execute it on Playwright, you will get a zip file. To avoid errors on the executor, verify that you have unzip or install it with the next command.
For Ubuntu or Linux based:
sudo apt-get install -y unzip
For MacOS:
brew install unzip
Using JSON on shell (JQ)
Another package that you need is jq to use JSON on shell or bash files. To verify that you have installed or install it, use the next command.
For Ubuntu or Linux based:
sudo apt-get install jq
For MacOS:
brew install jq
Installing Playwright
Go to the folder you created previously in the Prerequisites section. If you skipped that section, then create a new directory to use Playwright. You can decide the folder location and the name.
In the folder, install Playwright it's dependencies using the following commands:
npm install -D @playwright/test
npx playwright install --with-deps chromium
Before running the script
Please install the following libraries (axios, archiver, cheerio, xpath, faker, xmldom, faker).
The following commands work for both MacOS and Ubuntu or Linux based.
npm install axios
npm install archiver
npm install cheerio
npm install xpath
npm install @xmldom/xmldom
npm install @faker-js/faker
Download the executor
To download the executor, use this command to clone the git project to your machine.
git clone https://github.com/muuklabs/pw_executor.git
Once you have the zip file with the project, unzip it to your project folder and you will have a new file called mkclipw.sh
Before to use it, you need to change the script to execution mode using the following command.
chmod +x mkclipw.sh
Once you have done it, you can start to use your MuukTest Playwright Executor
Execute a test
Once you installed and configured Playwright and the executor, you can start to execute tests with them.
The executor has this structure to use:
./mkclipw.sh {{property}} {{value}} {{key}}
Where:
- property is to indicate if you want to execute by tag or by hashtag.
- value the TC# for the test (in the case of Tag) or the name of the hashtag (in the case of Hashtag)
- key (optional) the content of the file that you download from your Account in the MuukTest Portal.
In this section you will practice using the key.pub on your project folder or writing on the shell.
Examples
- Using with Hashtag
./mkclipw.sh hashtag "#sample"
- Using with Tag
./mkclipw.sh tag "TC15123"
- Using with the key on the shell
./mkclipw.sh tag "TC12345" "Wesadsdad_asdadWWWCASsdd..."
Example with key.pub on project folder
Download your Key.pub file from your MuukTest account. You can download it from your Account in MuukTest Portal. Once you have it, put the file in the folder project.
On your shell, write the usage command with your tag/hashtag and value:
You will get an output like this (depending on your result).
Example without key.pub on project folder
Download your Key.pub file from your MuukTest account. You can download it from your account on the MuukTest Portal. Open it and copy the value:
Then, in your shell, write the usage command with your tag/hashtag, value and key:
Depending on your test result, you will receive an output like that in your shell.
And that is it! You can go to MuukTest Portal to see the execution result.
Bonus
If you want to see the browser execution live. Open the mkclipw.sh file and go to line 22, add the --headed parameter as seen in the command below.
npx playwright test --workers=1 --project=chromium --headed
And then, when you use your executor, you will see the browser and your execution.
And that's all! 🎉
Enjoy using MuukTest + Playwright.
Comments
0 comments
Please sign in to leave a comment.