nn-haywork-playwright-core
v1.0.2
Published
A library that helps you create an Automation Testing project on WebApp with the POM model
Downloads
94
Readme
Playwright Automation
Welcome to the Playwright Automation Testing Project! This repository contains a set of guidelines and instructions for setting up and using Playwright for automated testing.
Installation
Before you can start using this project, you need to ensure that you have the following prerequisites installed on your system:
Node.js: Make sure you have the latest version of Node.js installed on your machine. You can download it from nodejs.org.
Visual Studio Code: This project is best used with Visual Studio Code (VSCode). Make sure you have it installed on your system. You can download it from code.visualstudio.com.
Usage
Once you have set up the project and installed the required dependencies, you can use the following npm scripts for various tasks:
View Playwright Run IDE
To view the Playwright Run IDE, run the following command:
npm run uiCheck for Coding Issues (Linting)
To check for coding issues using ESLint, run:
npm run lintCheck Code Formatting Issues
To check for code formatting issues using Prettier, run:
npm run prettierEnvironment Configuration
playwright.config.tsget baseURL based onmy.envfile config.- Go to
my.envfile to change the environment
URL=${env}- Default to run on ${env}
process.env.BASE_URL =
process.env.URL === ${env}
? ${URL}
: ${URL};Start working
Set your user.name and user.name for the git
git config user.name ${name}
eg: Nhan Nguyengit config user.email ${email}Pull latest main branch
Checkout a new branch with
git checkout -b [your_branch_name][your_branch_name]should be the prefixes of your name and test case ID Eg:TL_TC01After you are done with the work in your branch, pull latest main then merge to your branch before making a pull request.
Once you make your PR, please include ${testLeadEmail} to the reviewers list
Suggested naming conventions for Element identifiers
| Category | UI/Control type | Prefix | Example | | -------- | -------------------------- | ------ | --------------- | | Basic | Button | btn | btnExit | | Basic | Check box | chk | chkReadOnly | | Basic | Combo box | cbo | cboEnglish | | Basic | Common dialog | dlg | dlgFileOpen | | Basic | Date picker | dtp | dtpPublished | | Basic | Dropdown List / Select tag | ddl | ddlCountry | | Basic | Form | frm | frmEntry | | Basic | Frame | fra | fraLanguage | | Basic | Image | img | imgIcon | | Basic | Label | lbl | lblHelpMessage | | Basic | Links/Anchor Tags | lnk | lnkForgotPwd | | Basic | List box | lst | lstPolicyCodes | | Basic | Menu | mnu | mnuFileOpen | | Basic | Radio button / group | rdo | rdoGender | | Basic | RichTextBox | rtf | rtfReport | | Basic | Table | tbl | tblCustomer | | Basic | TabStrip | tab | tabOptions | | Basic | Text Area | txa | txaDescription | | Basic | Text box | txt | txtLastName | | Complex | Chevron | chv | chvProtocol | | Complex | Data grid | dgd | dgdTitles | | Complex | Data list | dbl | dblPublisher | | Complex | Directory list box | dir | dirSource | | Complex | Drive list box | drv | drvTarget | | Complex | File list box | fil | filSource | | Complex | Panel/Fieldset | pnl | pnlGroup | | Complex | ProgressBar | prg | prgLoadFile | | Complex | Slider | sld | sldScale | | Complex | Spinner | spn | spnPages | | Complex | StatusBar | sta | staDateTime | | Complex | Timer | tmr | tmrAlarm | | Complex | Toolbar | tlb | tlbActions | | Complex | TreeView | tre | treOrganization |
API Testing
${projectName} provides a rich set of APIs with full automation capability for managing and working within the workspace.
Prerequisites
- ${projectName} account,
Generate Secure Workspace API key:
- Log in to the ${projectName} web console
- Go to Settings -> API Keys -> Generate API Key
- Copy the API key
- Go to
user.jsonfile on this framework - Update the
apikeywith the API key with the User Role
Authentication and Access Tokens
There are two types of tokens available:
iam_token: Used for Secure Workspace IAM operations, such as authentication, user management, group management, etc.sdp_token: Used for Secure Workspace zero trust application management operations, such as application provisioning, client management, etc.
async function globalSetup() {
const users = UsersData.load();
const apiKey: string = users.superAdmin.apiKey;
// GET SERVICE API AUTH TOKEN
try {
const resp: APIResponse = await (
await request.newContext()
).post(`${process.env.BASE_URL}/iam/v1/apikey/authenticate`, {
headers: {
"Content-Type": "application/json",
},
data: {
apikey: apiKey,
},
timeout: 300000,
});
}
}