update
Some checks failed
Spell Check / Spell Check with Typos (push) Failing after 6s

This commit is contained in:
Linpiing 2025-05-22 09:17:46 +07:00 committed by Methapon2001
parent 0150f80ba2
commit 272183bca9
77 changed files with 9957 additions and 144 deletions

View file

@ -1,9 +1,10 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import fs from 'fs';
import fs, { writeFileSync } from 'fs';
import path from 'path';
let page: Page;
let isLoginSuccessful = false;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
@ -15,63 +16,76 @@ test.afterAll(async () => {
}
});
async function login(page: Page) {
try {
// Login
await page.goto('http://192.168.1.62:20101/');
await expect(page).toHaveTitle(/^Sign in to /);
await page.fill("input[name='username']", 'admin');
await page.fill("input[name='password']", '1234');
await page.click('id=kc-login');
await page.waitForTimeout(2000);
// await page.click('id=acceptBtn');
// เข้าสู่เมนูลูกค้า
await page.click('id=menu.manage');
await page.waitForSelector('id=sub-menu-customer');
await page.click('id=sub-menu-customer');
await page.waitForTimeout(2000);
isLoginSuccessful = true;
console.log('Login สำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการ Login', error);
isLoginSuccessful = false;
}
}
test('Login', async () => {
// Login
await page.goto('http://chamomind.ddns.net:20001/');
await expect(page).toHaveTitle(/^Sign in to /);
await page.fill("input[name='username']", 'admin');
await page.fill("input[name='password']", '1234');
await page.click('id=kc-login');
await page.waitForTimeout(2000);
// await page.click('id=acceptBtn');
await login(page);
});
test('สร้างลูกจ้างในสาขา', async () => {
const names = [
{
firstName: 'อริญา',
lastName: 'จิตรเกียรติ',
firstNameEn: 'Arinya',
lastNameEn: 'Jitkiat',
},
{
firstName: 'เกียรติศักดิ์',
lastName: 'อำนวย',
firstNameEn: 'Kiatsakd',
lastNameEn: 'Amnuy',
},
{
firstName: 'ภัทรพล',
lastName: 'รุ่งโรจน์',
firstNameEn: 'Phatthapon',
lastNameEn: 'Rungroj',
},
{
firstName: 'ศิริพร',
lastName: 'พงษ์รัตน์',
firstNameEn: 'Siriporn',
lastNameEn: 'Phongrat',
},
{
firstName: 'กรกมล',
lastName: 'กิตติสมบัติ',
firstNameEn: 'Karakamon',
lastNameEn: 'Kittisombat',
},
];
// เข้าสู่เมนูลูกค้า
await page.click('id=menu.manage');
await page.waitForSelector('id=sub-menu-customer');
await page.click('id=sub-menu-customer');
await page.click(
"//td[contains(.,'บริษัท เทคโนโลยีอินโนเวต จำกัดInnovative Technology Co., Ltd.')]",
);
await page.click("//table[@class='q-table']/tbody[1]/tr[3]/td[6]/button[1]");
if (!isLoginSuccessful) {
await login(page);
}
try {
const names = [
{
firstName: 'เกียรติศักดิ์',
lastName: 'อำนวย',
firstNameEn: 'Kiatsakd',
lastNameEn: 'Amnuy',
},
{
firstName: 'ภัทรพล',
lastName: 'รุ่งโรจน์',
firstNameEn: 'Phatthapon',
lastNameEn: 'Rungroj',
},
{
firstName: 'ศิริพร',
lastName: 'พงษ์รัตน์',
firstNameEn: 'Siriporn',
lastNameEn: 'Phongrat',
},
{
firstName: 'กรกมล',
lastName: 'กิตติสมบัติ',
firstNameEn: 'Karakamon',
lastNameEn: 'Kittisombat',
},
];
await page.click(
"//td[contains(.,'บริษัท เอกซ์เซล อินโนเวชั่น จำกัดSiam Energy Solutions Co., Ltd.')]",
);
await page.click('id=btn-show-employee-บริษัท เอกซ์เซล อินโนเวชั่น จำกัด');
for (const user of names) {
await page.click("(//th[@class='text-right']//button)[2]");
await page.waitForSelector(
'id=บริษัท เอกซ์เซล อินโนเวชั่น จำกัด-btn-add-employee',
);
await page.click('id=บริษัท เอกซ์เซล อินโนเวชั่น จำกัด-btn-add-employee');
await page.click('id=form-employee-select-prefix-name');
await page.click('id=form-employee-select-prefix-name_0');
await page.fill('id=form-employee-input-first-name', user.firstName);
@ -82,8 +96,8 @@ test('สร้างลูกจ้างในสาขา', async () => {
// วันเกิด
await page.click('id=form-employee-input-birth-date');
await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]");
await page.click("//div[text()='2000']");
await page.click("//div[@id='2000-11-02']/div[1]");
await page.click("//div[text()='1999']");
await page.click("//div[@id='1999-12-02']/div[1]");
// สัญชาติ
await page.click('id=form-employee-select-nationality');
@ -98,27 +112,31 @@ test('สร้างลูกจ้างในสาขา', async () => {
});
test('สร้างลูกจ้างในสาขา 2', async () => {
const namestwo = [
{
firstName: 'สุทิน',
lastName: 'ภาณุวงศ์',
firstNameEn: 'Suthin',
lastNameEn: 'Phanuwong',
},
];
if (!isLoginSuccessful) {
await login(page);
}
// เข้าสู่เมนูลูกค้า
await page.click('id=menu.manage');
await page.waitForSelector('id=sub-menu-customer');
await page.click('id=sub-menu-customer');
await page.click(
"//td[contains(.,'บริษัท เทคโนโลยีอินโนเวต จำกัดInnovative Technology Co., Ltd.')]",
);
await page.click("//table[@class='q-table']/tbody[1]/tr[5]/td[6]/button[1]");
try {
const namestwo = [
{
firstName: 'สุทิน',
lastName: 'ภาณุวงศ์',
firstNameEn: 'Suthin',
lastNameEn: 'Phanuwong',
},
];
await page.click(
"//td[contains(.,'บริษัท เอกซ์เซล อินโนเวชั่น จำกัดSiam Energy Solutions Co., Ltd.')]",
);
await page.click('id=btn-show-employee-บริษัท เอกซ์เซล อินโนเวชั่น จำกัด');
for (const user of namestwo) {
await page.click("(//th[@class='text-right']//button)[3]");
await page.waitForSelector(
'id=บริษัท เอกซ์เซล อินโนเวชั่น จำกัด-btn-add-employee',
);
await page.click('id=บริษัท เอกซ์เซล อินโนเวชั่น จำกัด-btn-add-employee');
await page.click('id=form-employee-select-prefix-name');
await page.click('id=form-employee-select-prefix-name_0');
await page.fill('id=form-employee-input-first-name', user.firstName);
@ -129,8 +147,8 @@ test('สร้างลูกจ้างในสาขา 2', async () => {
// วันเกิด
await page.click('id=form-employee-input-birth-date');
await page.click("(//button[@class='dp__btn dp__month_year_select'])[2]");
await page.click("//div[text()='2000']");
await page.click("//div[@id='2000-11-02']/div[1]");
await page.click("//div[text()='1999']");
await page.click("//div[@id='1999-12-02']/div[1]");
// สัญชาติ
await page.click('id=form-employee-select-nationality');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -18,7 +18,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -19,7 +19,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -16,7 +16,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -18,7 +18,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -19,7 +19,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -16,7 +16,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -16,7 +16,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -15,7 +15,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -18,7 +18,7 @@ test.afterAll(async () => {
});
//สร้าง Function สำหรับ Login
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');

View file

@ -14,7 +14,7 @@ test.afterAll(async () => {
}
});
async function login(page) {
async function login(page: Page) {
try {
// Login
await page.goto('/');