test : Create Script Role&Permission

This commit is contained in:
Linpiing 2024-09-18 17:52:25 +07:00
parent 5bc28bf893
commit 9254c0183e
67 changed files with 11224 additions and 729 deletions

View file

@ -1,5 +1,6 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import path from 'path';
import { off } from 'process';
let page: Page;
@ -25,19 +26,167 @@ test('Login', async () => {
});
test('Create Branch Managenment', async () => {
await page.click('id=menu-icon-branch-management');
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
try {
await page.click('id=menu-icon-branch-management');
await page.click('id=hq-add-btn');
// await page.click('id=btn-Add');
// await page.click("(//div[@class='q-avatar relative-position'])[2]");
// const fileInput = page.locator(
// "//div[@class='image-dialog-body']//button[1]",
// );
// await fileInput.waitFor({ state: 'visible' });
// // อัปโหลดไฟล์
// await fileInput.setInputFiles(
// '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg',
// ); // เปลี่ยน path ให้ตรง
// await page.setInputFiles(
// "//div[@class='image-dialog-body']//button[1]",
// '/Users/linping/Desktop/Chamomind&FrappeT/JWS_TestScript/tests/Datafile/Pic1.jpg',
// );
// // UploadFile
// ส่วนข้อมูลพื้นฐาน
await page.fill("(//input[@id='input-abbreviation'])[2]", 'CMM');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[3]", 'บริษัท คาโมมายด์ จำกัด');
await page.fill("(//input[@id='input-name-en'])[2]", 'CHAMOMIND');
await page.fill(
"(//input[@aria-label='เลขที่ใบอนุญาต'])[2]",
'1228222822822',
);
// ส่วนติดต่อ
await page.fill("(//input[@id='input-email'])[2]", 'cmm@support.com');
await page.fill("(//input[@id='input-telephone-no'])[2]", '022222262');
await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณต่อ');
await page.fill("(//input[@id='input-contact'])[2]", '0866224228');
await page.fill("(//input[@id='input-line-id'])[2]", 'local2024');
// ส่วนที่อยู่
await page.fill("(//input[@id='default-input-address-no'])[2]", '20/02');
await page.fill("(//input[@id='default-input-moo'])[3]", '1');
await page.click("(//input[@id='default-select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-district'])[2]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-sub-district'])[2]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='default-input-address-en'])[2]", '20/02');
await page.fill("(//input[@aria-label='Moo'])[2]", '1');
//ส ส่วนบัญชีธนาคาร
await page.click("(//input[@id='select-bankbook'])[3]");
await page.click('id=select-bankbook_1');
await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '1202282262226');
await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'เชียงใหม่');
await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana');
await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]");
await page.waitForTimeout(2000);
await page.click('id=select-bankbook_0');
await page.click('id=btn-form-submit');
await page.waitForSelector('id=btn-ok-dialog');
await page.click('id=btn-ok-dialog');
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
const newOfficeLocator = page.locator(
"//td[contains(.,'บริษัท คาโมมายด์ จำกัดCMM00000')]",
);
await newOfficeLocator.waitFor({ state: 'visible' });
// ดึงข้อความจาก <td> ที่ตรงกับ XPath
const newOfficeName = await newOfficeLocator.textContent();
// ตรวจสอบว่าเนื้อหาที่บันทึกถูกต้อง
if (newOfficeName !== null) {
const trimmedName = newOfficeName.trim();
expect(trimmedName).toBe('บริษัท คาโมมายด์ จำกัดCMM00000');
console.log('การตรวจสอบสำเร็จ: ข้อมูลถูกต้อง');
} else {
throw new Error('ไม่พบข้อมูลที่บันทึกใน <td>');
}
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});
test('Create Branch Managenment Second', async () => {
try {
// ส่วนข้อมูลพื้นฐาน
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-abbreviation'])[2]", 'CMO');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[3]", 'บริษัท โคโม่ จำกัด');
await page.fill("(//input[@id='input-name-en'])[2]", 'COMO');
await page.fill(
"(//input[@aria-label='เลขที่ใบอนุญาต'])[2]",
'1228222822822',
);
// ส่วนติดต่อ
await page.fill("(//input[@id='input-email'])[2]", 'como@support.com');
await page.fill("(//input[@id='input-telephone-no'])[2]", '022010100');
await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท');
await page.fill("(//input[@id='input-contact'])[2]", '0866224228');
await page.fill("(//input[@id='input-line-id'])[2]", 'como20');
// ส่วนที่อยู่
await page.fill("(//input[@id='default-input-address-no'])[2]", '40/04');
await page.fill("(//input[@id='default-input-moo'])[3]", '2');
await page.click("(//input[@id='default-select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-district'])[2]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-sub-district'])[2]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='default-input-address-en'])[2]", '40/04');
await page.fill("(//input[@aria-label='Moo'])[2]", '1');
// ส่วนธนาคาร
await page.click("(//input[@id='select-bankbook'])[3]");
await page.click('id=select-bankbook_4');
await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2022822624262');
await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน');
await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana');
await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]");
await page.waitForTimeout(2000);
await page.click('id=select-bankbook_0');
await page.click('id=btn-form-submit');
await page.waitForSelector('id=btn-ok-dialog');
await page.click('id=btn-ok-dialog');
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
const newOfficeLocator = page.locator(
"//td[contains(.,'บริษัท โคโม่ จำกัดCMO00000')]",
);
await newOfficeLocator.waitFor({ state: 'visible' });
// ดึงข้อความจาก <td> ที่ตรงกับ XPath
const newOfficeName = await newOfficeLocator.textContent();
// ตรวจสอบว่าเนื้อหาที่บันทึกถูกต้อง
if (newOfficeName !== null) {
const trimmedName = newOfficeName.trim();
expect(trimmedName).toBe('บริษัท โคโม่ จำกัดCMO00000');
console.log('การตรวจสอบสำเร็จ: ข้อมูลถูกต้อง');
} else {
throw new Error('ไม่พบข้อมูลที่บันทึกใน <td>');
}
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});

View file

@ -1,5 +1,6 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import exp from 'constants';
let page: Page;
@ -24,106 +25,122 @@ test('Login', async () => {
// await page.click('id=acceptBtn');
});
test('Create Branch Managenment Not input data', async () => {
test('Create Branch Management - ไม่มีการกรอกข้อมูล', async () => {
await page.click('id=menu-icon-branch-management');
await page.click('id=hq-add-btn');
await page.click('id=submitBtn');
await page.click('id=btn-form-submit');
const abbreviationError = page.locator(
"(//div[@class='q-field__messages col'])[1]",
);
const taxNoError = page.locator(
"(//div[@class='q-field__messages col']//div)[2]",
);
const nameError = page.locator(
"(//div[@class='q-field__messages col']//div)[3]",
);
const nameEnError = page.locator(
"(//div[@class='q-field__messages col']//div)[4]",
);
const LicenseNumberError = page.locator(
"(//div[@class='q-field__messages col']//div)[5]",
);
const addressError = page.locator(
"(//div[@class='q-field__messages col']//div)[6]",
);
const provinceError = page.locator(
"(//div[@class='q-field__messages col']//div)[7]",
);
const districtError = page.locator(
"(//div[@class='q-field__messages col']//div)[8]",
);
const subDistrictError = page.locator(
"(//div[@class='q-field__messages col']//div)[9]",
);
const addressEnError = page.locator(
"(//div[@class='q-field__messages col']//div)[10]",
);
await expect(abbreviationError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้', {
timeout: 2000,
});
await expect(taxNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(nameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(nameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(LicenseNumberError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(provinceError).toHaveText('โปรดเลือกจังหวัด');
await expect(districtError).toHaveText('โปรดเลือกอำเภอ');
await expect(subDistrictError).toHaveText('โปรดเลือกตำบล');
await expect(addressEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
await page.click('id=btn-form-cancel');
console.log('การตรวจสอบ Validation ถูกต้อง');
});
test('Create Branch Managenment Not input Tax', async () => {
test('Create Branch Managenment - กรณีที่กรอกชื่อย่อที่ไม่ใช่ภาษาอังกฤษ', async () => {
await page.reload();
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.fill("(//input[@id='input-abbreviation'])[2]", 'ภาษาไทย');
const invalidDataabbreviationError = page.locator(
// ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ
"(//div[contains(@class,'q-field__bottom row')])[1]",
);
await expect(invalidDataabbreviationError).toHaveText(
'ข้อมูลไม่ถูกต้อง โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษและตัวเลขเท่านั้น',
{
timeout: 2000,
},
);
console.log(
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่ไม่ใช่ภาษาอังกฤษถูกต้อง',
);
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
await page.click('id=btn-form-cancel');
});
test('Create Branch Managenment Not input Head Office Name Thai', async () => {
test('Create Branch Management - กรอกเลขนิติบุคคลในกรณีที่กรอกไม่ครบจำนวน 13 หลัก', async () => {
await page.reload();
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.fill("(//input[@id='input-tax-no'])[2]", '123');
const taxNoError = page.locator(
// ตรวจสอบการแสดง Validation แจ้งเตือนชื่อย่อในกรณีที่ไม่ใช้ภาษาอังกฤษ
"(//div[@class='q-field__messages col']//div)[2]",
);
await expect(taxNoError).toHaveText(
'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก',
{
timeout: 2000,
},
);
console.log(
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก',
);
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
await page.click('id=btn-form-cancel');
});
test('Create Branch Managenment Not input Head Office Name ENG', async () => {
test('Create Branch Management - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
await page.reload();
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
});
await page.fill("(//input[@id='input-email'])[2]", '123');
const emailError = page.locator(
// ตรวจสอบการแสดง Validation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ
"(//div[@class='q-field__messages col']//div)[2]",
);
test('Create Branch Managenment Not input Address TH ', async () => {
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
});
await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง', {
timeout: 2000,
});
console.log(
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ',
);
test('Create Branch Managenment Not input Address ENG', async () => {
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
});
test('Create Branch Managenment Not Select Province,District,Sub-District', async () => {
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
await page.click('id=btn-form-cancel');
});

View file

@ -25,21 +25,88 @@ test('Login', async () => {
});
test('Create Sub Branch Managenment', async () => {
await page.click('id=menu-icon-branch-management');
for (let i = 0; i < 10; i++) {
await page.click('id=create-sub-branch-btn-สีลม');
await page.fill("(//input[@id='input-tax-no'])[2]", `126084622028${i + 1}`);
await page.fill("(//input[@id='input-name'])[2]", `สีลม${i + 1}`);
await page.fill("(//input[@id='input-name-en'])[2]", `Silom${i + 1}`);
await page.fill("(//input[@id='input-address'])[2]", `20/0${i + 1}`);
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", `20/0${i + 1}`);
await page.click('id=submitBtn');
try {
await page.click('id=menu-icon-branch-management');
for (let i = 0; i < 5; i++) {
await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด');
await page.click("(//button[@type='submit'])[1]");
// ส่วนข้อมูลพื้นฐาน
await page.fill(
"(//input[@id='input-tax-no'])[2]",
`126084622028${i + 1}`,
);
await page.fill("(//input[@id='input-name'])[3]", `สีลม${i + 1}`);
await page.fill("(//input[@id='input-name-en'])[2]", `Silom${i + 1}`);
await page.fill(
"(//input[@aria-label='เลขที่ใบอนุญาต'])[2]",
'1228222822822',
);
// ส่วนติดต่อ
await page.fill(
"(//input[@id='input-email'])[2]",
`host${i + 1}@local.co.th`,
);
await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002');
await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท');
await page.fill("(//input[@id='input-contact'])[2]", `08622864${i + 1}`);
await page.fill("(//input[@id='input-line-id'])[2]", 'company');
await page.fill(
"(//input[@id='default-input-address-no'])[2]",
`20/0${i + 1}`,
);
await page.click("(//input[@id='default-select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-sub-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.fill(
"(//input[@id='default-input-address-en'])[2]",
`20/0${i + 1}`,
);
await page.click("(//input[@id='select-bankbook'])[3]");
await page.click(`id=select-bankbook_${i + 1}`);
await page.fill(
"(//input[@aria-label='เลขบัญชี'])[2]",
`228202002${i + 1}`,
);
await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'เชียงใหม่');
await page.fill(
"(//input[@aria-label='ชื่อบัญชี'])[2]",
'Pongpon Kuntana',
);
await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]");
await page.waitForTimeout(2000);
await page.click('id=select-bankbook_0');
await page.click('id=btn-form-submit');
}
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
const subBranchErrors = ['สีลม1', 'สีลม2', 'สีลม3', 'สีลม4', 'สีลม5'];
for (const branch of subBranchErrors) {
const subBranchErrors = page.locator(
`//div[normalize-space(text())='${branch}']`,
);
await subBranchErrors.waitFor({ state: 'visible' });
const newOfficeName = await subBranchErrors.textContent();
const trimmedName = newOfficeName?.trim();
expect(trimmedName).toBe(branch);
}
console.log('การตรวจสอบสำเร็จ : ข้อมูลถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(2000);
});

View file

@ -24,106 +24,93 @@ test('Login', async () => {
// await page.click('id=acceptBtn');
});
test('Create Sub-Branch Managenment Not input data', async () => {
test('Create Sub-Branch Managenment - ในกรณีที่ไม่กรอกข้อมูล', async () => {
await page.click('id=menu-icon-branch-management');
await page.click('id=create-sub-branch-btn-สีลม');
await page.click('id=submitBtn');
await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด');
await page.click("(//button[@type='submit'])[1]");
await page.click('id=btn-form-submit');
const taxNoError = page.locator(
"(//div[@class='q-field__messages col']//div)[1]",
);
const nameError = page.locator(
"(//div[@class='q-field__messages col']//div)[2]",
);
const nameEnError = page.locator(
"(//div[@class='q-field__messages col']//div)[3]",
);
const lincenseNumberError = page.locator(
"(//div[@class='q-field__messages col']//div)[4]",
);
const addressError = page.locator(
"(//div[@class='q-field__messages col']//div)[5]",
);
const provinceError = page.locator(
"(//div[@class='q-field__messages col']//div)[6]",
);
const districtError = page.locator(
"(//div[@class='q-field__messages col']//div)[7]",
);
const subDistrictError = page.locator(
"(//div[@class='q-field__messages col']//div)[8]",
);
const addressEnError = page.locator(
"(//div[@class='q-field__messages col']//div)[9]",
);
await expect(taxNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(nameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(nameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(lincenseNumberError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(provinceError).toHaveText('โปรดเลือกจังหวัด');
await expect(districtError).toHaveText('โปรดเลือกอำเภอ');
await expect(subDistrictError).toHaveText('โปรดเลือกตำบล');
await expect(addressEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
await page.click('id=btn-form-cancel');
console.log('การตรวจสอบ Validation ถูกต้อง');
});
test('Create Sub-Branch Managenment Not input Tax', async () => {
await page.click('id=create-sub-branch-btn-สีลม');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
test('Create Sub-Branch Managenment - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => {
await page.reload();
await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด');
await page.click("(//button[@type='submit'])[1]");
await page.fill("(//input[@id='input-tax-no'])[2]", '123');
// ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก
const taxNoError = page.locator(
"(//div[@class='q-field__messages col']//div)[1]",
);
await expect(taxNoError).toHaveText(
'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก',
);
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
await page.click('id=btn-form-cancel');
console.log(
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง',
);
});
test('Create Sub-Branch Managenment Not input Head Office Name Thai', async () => {
await page.click('id=create-sub-branch-btn-สีลม');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
});
test('Create Sub-Branch Managenment - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
await page.reload();
await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด');
await page.click("(//button[@type='submit'])[1]");
await page.fill("(//input[@id='input-email'])[2]", 'email');
test('Create Sub-Branch Managenment Not input Head Office Name ENG', async () => {
await page.click('id=create-sub-branch-btn-สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
});
// ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก
const emailError = page.locator(
"(//div[@class='q-field__messages col']//div)[2]",
);
test('Create Sub-Branch Managenment Not input Address TH ', async () => {
await page.click('id=create-sub-branch-btn-สีลม');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
});
await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง');
test('Create Sub-Branch Managenment Not input Address ENG', async () => {
await page.click('id=create-sub-branch-btn-สีลม');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.click("(//div[@id='select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//div[@id='select-district'])[2]");
await page.click("//span[text()='เมือง']");
await page.click("(//div[@id='select-sub-district'])[2]");
await page.click("//span[text()='ช้างเผือก']");
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
});
test('Create Sub-Branch Managenment Not Select Province,District,Sub-District', async () => {
await page.click('id=create-sub-branch-btn-สีลม');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'สีลม');
await page.fill("(//input[@id='input-name-en'])[2]", 'Silom');
await page.fill("(//input[@id='input-address'])[2]", '20/02 ');
await page.fill("(//input[@id='input-address-en'])[2]", '20/02');
await page.click('id=submitBtn');
await page.waitForTimeout(4000);
await page.click("(//button[@id='closeDialog'])[2]");
await page.click('id=btn-form-cancel');
console.log(
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
);
});

View file

@ -0,0 +1,118 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Create Service Point Managenment', async () => {
try {
await page.click('id=menu-icon-branch-management');
for (let i = 0; i < 5; i++) {
await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด');
await page.click("(//button[@type='submit'])[2]");
// ส่วนข้อมูลพื้นฐาน
await page.fill(
"(//input[@id='input-tax-no'])[2]",
`202282628264${i + 1}`,
);
await page.fill("(//input[@id='input-name'])[3]", `บางรัก${i + 1}`);
await page.fill("(//input[@id='input-name-en'])[2]", `Bangrak${i + 1}`);
await page.fill(
"(//input[@aria-label='เลขที่ใบอนุญาต'])[2]",
'1228222822822',
);
// ส่วนติดต่อ
await page.fill(
"(//input[@id='input-email'])[2]",
`cmm${i + 1}@local.co.th`,
);
await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002');
await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอุล');
await page.fill("(//input[@id='input-contact'])[2]", `082262286${i + 1}`);
await page.fill("(//input[@id='input-line-id'])[2]", 'cmmsupport');
await page.fill(
"(//input[@id='default-input-address-no'])[2]",
`40/0${i + 1}`,
);
await page.click("(//input[@id='default-select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-sub-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.fill(
"(//input[@id='default-input-address-en'])[2]",
`40/0${i + 1}`,
);
await page.click("(//input[@id='select-bankbook'])[3]");
await page.click(`id=select-bankbook_${i + 1}`);
await page.fill(
"(//input[@aria-label='เลขบัญชี'])[2]",
`282264220${i + 1}`,
);
await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน');
await page.fill(
"(//input[@aria-label='ชื่อบัญชี'])[2]",
'Pongpon Kuntana',
);
await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]");
await page.waitForTimeout(2000);
await page.click('id=select-bankbook_0');
await page.click('id=btn-form-submit');
}
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
const subBranchErrors = [
'บางรัก1',
'บางรัก2',
'บางรัก3',
'บางรัก4',
'บางรัก5',
];
for (const branch of subBranchErrors) {
const subBranchErrors = page.locator(
`//div[normalize-space(text())='${branch}']`,
);
await subBranchErrors.waitFor({ state: 'visible' });
const newOfficeName = await subBranchErrors.textContent();
const trimmedName = newOfficeName?.trim();
expect(trimmedName).toBe(branch);
}
console.log('การตรวจสอบสำเร็จ : ข้อมูลถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(2000);
});

View file

@ -1,91 +0,0 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Select Type Branch Name Out', async () => {
await page.click('id=menu-icon-branch-management');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[1]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Telephone No. Out', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[2]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Address Out', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[3]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Type Out', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[4]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Status Out', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[5]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Name In', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[1]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Telephone No. In', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[2]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Address In', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[3]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Type In', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[4]");
await page.waitForTimeout(2000);
});
test('Select Type Branch Status In', async () => {
await page.keyboard.press('Escape');
await page.click("//span[text()='ข้อมูลที่แสดง']");
await page.click("(//div[@role='option'])[5]");
await page.waitForTimeout(2000);
});

View file

@ -0,0 +1,112 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Create Service Point - ในกรณีที่ไม่กรอกข้อมูล', async () => {
await page.click('id=menu-icon-branch-management');
await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด');
await page.click("(//button[@type='submit'])[2]");
await page.click('id=btn-form-submit');
const taxNoError = page.locator(
"(//div[@class='q-field__messages col']//div)[1]",
);
const nameError = page.locator(
"(//div[@class='q-field__messages col']//div)[2]",
);
const nameEnError = page.locator(
"(//div[@class='q-field__messages col']//div)[3]",
);
const addressError = page.locator(
"(//div[@class='q-field__messages col']//div)[4]",
);
const provinceError = page.locator(
"(//div[@class='q-field__messages col']//div)[5]",
);
const districtError = page.locator(
"(//div[@class='q-field__messages col']//div)[6]",
);
const subDistrictError = page.locator(
"(//div[@class='q-field__messages col']//div)[7]",
);
const addressEnError = page.locator(
"(//div[@class='q-field__messages col']//div)[8]",
);
await expect(taxNoError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(nameError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(nameEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(addressError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await expect(provinceError).toHaveText('โปรดเลือกจังหวัด');
await expect(districtError).toHaveText('โปรดเลือกอำเภอ');
await expect(subDistrictError).toHaveText('โปรดเลือกตำบล');
await expect(addressEnError).toHaveText('จำเป็นต้องกรอกข้อมูลนี้');
await page.waitForTimeout(4000);
await page.click('id=btn-form-cancel');
console.log('การตรวจสอบ Validation ถูกต้อง');
});
test('Create Service Point - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => {
await page.reload();
await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด');
await page.click("(//button[@type='submit'])[2]");
await page.fill("(//input[@id='input-tax-no'])[2]", '123');
// ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก
const taxNoError = page.locator(
"(//div[@class='q-field__messages col']//div)[1]",
);
await expect(taxNoError).toHaveText(
'ข้อมูลไม่ถูกต้อง กรุณากรอกให้ครบ 13 หลัก',
);
await page.waitForTimeout(4000);
await page.click('id=btn-form-cancel');
console.log(
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง',
);
});
test('Create Service Point - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
await page.reload();
await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด');
await page.click("(//button[@type='submit'])[2]");
await page.fill("(//input[@id='input-email'])[2]", 'email');
// ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก
const emailError = page.locator(
"(//div[@class='q-field__messages col']//div)[2]",
);
await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง');
await page.waitForTimeout(4000);
await page.click('id=btn-form-cancel');
console.log(
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
);
});

View file

@ -1,33 +0,0 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('View Detail', async () => {
await page.click('id=menu-icon-branch-management');
await page.click('id=view-detail-btn-สีลม');
await page.click('id=view-detail-btn-สีลม-view');
await page.waitForTimeout(4000);
await page.click('id=closeDialog');
});

View file

@ -1,37 +0,0 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Edit Branch', async () => {
await page.click('id=menu-icon-branch-management');
await page.click('id=view-detail-btn-สีลม');
await page.click('id=view-detail-btn-สีลม-edit');
await page.fill("(//input[@id='input-name'])[2]", 'สาทร');
await page.fill("(//input[@id='input-name-en'])[2]", 'Sathorn');
await page.click("(//button[@id='submitBtn'])[2]");
await page.click('id=view-detail-btn-สาทร');
await page.click('id=view-detail-btn-สาทร-view');
await page.waitForTimeout(4000);
});

View file

@ -0,0 +1,387 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import { watchFile } from 'fs';
import { waitForDebugger } from 'inspector';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับที่', async () => {
try {
// คลิกเมนูเพื่อจัดการสาขา
await page.click('id=menu-icon-branch-management');
// คลิกเพื่อเปิด dropdown
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อปิดคอลัมน์ที่ 1
await page.click('id=select-field_0');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์ถูกซ่อน
const column1 = page.locator('id=select-field_0');
const column1Cells = page.locator(
"//th[normalize-space(text())='ลำดับที่']",
);
const isColumn1Hidden = await column1.evaluate(
(el) => window.getComputedStyle(el).display === 'none',
);
console.log('คอลัมน์ที่ 1 ซ่อนอยู่:', isColumn1Hidden); // เช็ค
const areCellsHidden = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display === 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 1 ซ่อนอยู่:', areCellsHidden); // เช็ค
expect(isColumn1Hidden).toBe(false);
expect(areCellsHidden).toBe(true);
// คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 1
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
await page.click('id=select-field_0'); // คลิกเพื่อเปิดคอลัมน์
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์แสดงอยู่
const isColumn1Visible = await column1.evaluate(
(el) => window.getComputedStyle(el).display !== 'none',
);
console.log('คอลัมน์ที่ 1 แสดงอยู่:', isColumn1Visible); // เช็ค
const areCellsVisible = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display !== 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 1 แสดงอยู่:', areCellsVisible); // เช็ค
expect(isColumn1Visible).toBe(true);
expect(areCellsVisible).toBe(true);
console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ', async () => {
try {
// คลิกเพื่อเปิด dropdown
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อปิดคอลัมน์ที่ 2
await page.click('id=select-field_1');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์ถูกซ่อน
const column1 = page.locator('id=select-field_1');
const column1Cells = page.locator(
"//th[normalize-space(text())='สำนักงาน']",
);
const isColumn1Hidden = await column1.evaluate(
(el) => window.getComputedStyle(el).display === 'none',
);
console.log('คอลัมน์ที่ 2 ซ่อนอยู่:', isColumn1Hidden); // เช็ค
const areCellsHidden = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display === 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 2 ซ่อนอยู่:', areCellsHidden); // เช็ค
expect(isColumn1Hidden).toBe(false);
expect(areCellsHidden).toBe(true);
// คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 2
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
await page.click('id=select-field_1'); // คลิกเพื่อเปิดคอลัมน์
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์แสดงอยู่
const isColumn1Visible = await column1.evaluate(
(el) => window.getComputedStyle(el).display !== 'none',
);
console.log('คอลัมน์ที่ 2 แสดงอยู่:', isColumn1Visible); // เช็ค
const areCellsVisible = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display !== 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 2 แสดงอยู่:', areCellsVisible); // เช็ค
expect(isColumn1Visible).toBe(true);
expect(areCellsVisible).toBe(true);
console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลทะเบียนนิติบุคคล', async () => {
try {
// คลิกเพื่อเปิด dropdown
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อปิดคอลัมน์ที่ 3
await page.click('id=select-field_2');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์ถูกซ่อน
const column1 = page.locator('id=select-field_2');
const column1Cells = page.locator(
"//th[normalize-space(text())='ทะเบียนนิติบุคคล']",
);
const isColumn1Hidden = await column1.evaluate(
(el) => window.getComputedStyle(el).display === 'none',
);
console.log('คอลัมน์ที่ 3 ซ่อนอยู่:', isColumn1Hidden); // เช็ค
const areCellsHidden = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display === 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 3 ซ่อนอยู่:', areCellsHidden); // เช็ค
expect(isColumn1Hidden).toBe(false);
expect(areCellsHidden).toBe(true);
// คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 3
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
await page.click('id=select-field_2'); // คลิกเพื่อเปิดคอลัมน์
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์แสดงอยู่
const isColumn1Visible = await column1.evaluate(
(el) => window.getComputedStyle(el).display !== 'none',
);
console.log('คอลัมน์ที่ 3 แสดงอยู่:', isColumn1Visible); // เช็ค
const areCellsVisible = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display !== 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 3 แสดงอยู่:', areCellsVisible); // เช็ค
expect(isColumn1Visible).toBe(true);
expect(areCellsVisible).toBe(true);
console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรสำนักงาน', async () => {
try {
// คลิกเพื่อเปิด dropdown
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อปิดคอลัมน์ที่ 4
await page.click('id=select-field_3');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์ถูกซ่อน
const column1 = page.locator('id=select-field_3');
const column1Cells = page.locator(
"//th[normalize-space(text())='เบอร์โทรสำนักงาน']",
);
const isColumn1Hidden = await column1.evaluate(
(el) => window.getComputedStyle(el).display === 'none',
);
console.log('คอลัมน์ที่ 4 ซ่อนอยู่:', isColumn1Hidden); // เช็ค
const areCellsHidden = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display === 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 4 ซ่อนอยู่:', areCellsHidden); // เช็ค
expect(isColumn1Hidden).toBe(false);
expect(areCellsHidden).toBe(true);
// คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 4
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
await page.click('id=select-field_3'); // คลิกเพื่อเปิดคอลัมน์
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์แสดงอยู่
const isColumn1Visible = await column1.evaluate(
(el) => window.getComputedStyle(el).display !== 'none',
);
console.log('คอลัมน์ที่ 4 แสดงอยู่:', isColumn1Visible); // เช็ค
const areCellsVisible = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display !== 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 4 แสดงอยู่:', areCellsVisible); // เช็ค
expect(isColumn1Visible).toBe(true);
expect(areCellsVisible).toBe(true);
console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลติดต่อ', async () => {
try {
// คลิกเพื่อเปิด dropdown
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อปิดคอลัมน์ที่ 5
await page.click('id=select-field_4');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์ถูกซ่อน
const column1 = page.locator('id=select-field_4');
const column1Cells = page.locator("//th[normalize-space(text())='ติดต่อ']");
const isColumn1Hidden = await column1.evaluate(
(el) => window.getComputedStyle(el).display === 'none',
);
console.log('คอลัมน์ที่ 5 ซ่อนอยู่:', isColumn1Hidden); // เช็ค
const areCellsHidden = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display === 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 5 ซ่อนอยู่:', areCellsHidden); // เช็ค
expect(isColumn1Hidden).toBe(false);
expect(areCellsHidden).toBe(true);
// คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 5
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
await page.click('id=select-field_4'); // คลิกเพื่อเปิดคอลัมน์
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์แสดงอยู่
const isColumn1Visible = await column1.evaluate(
(el) => window.getComputedStyle(el).display !== 'none',
);
console.log('คอลัมน์ที่ 5 แสดงอยู่:', isColumn1Visible); // เช็ค
const areCellsVisible = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display !== 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 5 แสดงอยู่:', areCellsVisible); // เช็ค
expect(isColumn1Visible).toBe(true);
expect(areCellsVisible).toBe(true);
console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลที่อยู่', async () => {
try {
// คลิกเพื่อเปิด dropdown
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อปิดคอลัมน์ที่ 6
await page.click('id=select-field_5');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์ถูกซ่อน
const column1 = page.locator('id=select-field_5');
const column1Cells = page.locator(
"//th[normalize-space(text())='ที่อยู่']",
);
const isColumn1Hidden = await column1.evaluate(
(el) => window.getComputedStyle(el).display === 'none',
);
console.log('คอลัมน์ที่ 6 ซ่อนอยู่:', isColumn1Hidden); // เช็ค
const areCellsHidden = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display === 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 6 ซ่อนอยู่:', areCellsHidden); // เช็ค
expect(isColumn1Hidden).toBe(false);
expect(areCellsHidden).toBe(true);
// คลิกอีกครั้งเพื่อเปิดคอลัมน์ที่ 6
await page.keyboard.press('Escape');
await page.click("(//input[@id='select-field'])[1]");
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
await page.click('id=select-field_5'); // คลิกเพื่อเปิดคอลัมน์
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าคอลัมน์แสดงอยู่
const isColumn1Visible = await column1.evaluate(
(el) => window.getComputedStyle(el).display !== 'none',
);
console.log('คอลัมน์ที่ 6 แสดงอยู่:', isColumn1Visible); // เช็ค
const areCellsVisible = await column1Cells.evaluateAll((cells) =>
cells.every((cell) => window.getComputedStyle(cell).display !== 'none'),
);
console.log('เซลล์ในคอลัมน์ที่ 6 แสดงอยู่:', areCellsVisible); // เช็ค
expect(isColumn1Visible).toBe(true);
expect(areCellsVisible).toBe(true);
console.log('ตรวจสอบการเปิด/ซ่อนคอลัมน์ในตารางสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});

View file

@ -1,58 +0,0 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Close Status Branch Headquater', async () => {
await page.click('id=menu-icon-branch-management');
await page.click('id=view-detail-btn-สาทร');
await page.click(
"//div[contains(@class,'q-toggle__inner relative-position')]",
);
await page.waitForTimeout(2000);
await page.keyboard.press('Escape');
});
test('Open Status Branch Headquater', async () => {
await page.click('id=view-detail-btn-สาทร');
await page.click(
"//div[contains(@class,'q-toggle__inner relative-position')]",
);
await page.waitForTimeout(2000);
await page.keyboard.press('Escape');
});
test('Close Status Sub-Branch Headquater', async () => {
await page.click(
"(//div[contains(@class,'q-tree__node-header relative-position')])[3]",
);
await page.click('id=branch-card-สาทร');
await page.click('id=view-detail-btn-สีลม3');
await page.click(
"//div[contains(@class,'q-toggle__inner relative-position')]",
);
await page.waitForTimeout(2000);
await page.keyboard.press('Escape');
await page.waitForTimeout(4000);
});

View file

@ -0,0 +1,91 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('View Detail Headquter Branch', async () => {
try {
await page.click('id=menu-icon-branch-management');
await page.click('id=btn-kebab-action-บริษัท โคโม่ จำกัด');
await page.click('id=btn-kebab-view-detail-บริษัท โคโม่ จำกัด');
const detailTitle = page.locator(
"//span[text()='บริษัท โคโม่ จำกัด ']/following-sibling::span",
);
await expect(detailTitle).toHaveText('CMO00000'); // เลขรหัสสำนักงานใหญ่
console.log('ตรวจสอบข้อมูลถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(4000);
await page.click('id=btn-info-close');
});
test('View Detail Sub Branch', async () => {
try {
await page.click("(//div[@id='tree-enter-บริษัท โคโม่ จำกัด']//div)[1]");
await page.click('id=btn-kebab-action-สีลม1');
await page.click('id=btn-kebab-view-detail-สีลม1');
const detailTitle = page.locator("//span[text()='สีลม1 ']");
await detailTitle.waitFor({ state: 'visible' });
await expect(detailTitle).toHaveText('สีลม1'); // เลขรหัสสำนักงานใหญ่
console.log('ตรวจสอบข้อมูลถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(4000);
await page.click('id=btn-info-close');
});
test('View Detail Service Point', async () => {
try {
await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]");
await page.click('id=btn-kebab-action-บางรัก1');
await page.click('id=btn-kebab-view-detail-บางรัก1');
const detailTitle = page.locator("//span[text()='บางรัก1 ']");
await detailTitle.waitFor({ state: 'visible' });
await expect(detailTitle).toHaveText('บางรัก1'); // เลขรหัสสำนักงานใหญ่
console.log('ตรวจสอบข้อมูลถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(4000);
await page.click('id=btn-info-close');
});

View file

@ -0,0 +1,129 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import exp from 'constants';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Edit Headquter Branch', async () => {
try {
// แก้ไขสำนักงานใหญ่
await page.click('id=menu-icon-branch-management');
await page.click('id=btn-kebab-action-บริษัท โคโม่ จำกัด');
await page.click('id=btn-kebab-edit-บริษัท โคโม่ จำกัด');
await page.fill('id=input-name', 'บริษัท โคโมโดะ จำกัด');
await page.fill('id=input-name-en', 'COMODO');
await page.click('id=btn-info-basic-save');
//ตรวจสอบรายละเอียดการแก้ไข
await page.click('id=btn-kebab-action-บริษัท โคโมโดะ จำกัด');
await page.click('id=btn-kebab-view-detail-บริษัท โคโมโดะ จำกัด');
//ตรวจสอบว่าได้ทำการแก้ไขถูกต้องหรือไม่
const detailEditName = await page.inputValue(
"//input[@value='บริษัท โคโมโดะ จำกัด']",
);
const detailEditNameEn = await page.inputValue(
"//input[@aria-label='ชื่อสำนักงานใหญ่ (EN)']",
);
await expect(detailEditName).toBe('บริษัท โคโมโดะ จำกัด');
await expect(detailEditNameEn).toBe('COMODO');
console.log('ตรวจสอบการแก้ไขข้อมูลสำนักงานใหญ่ถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(4000);
await page.click('id=btn-info-close');
});
test('Edit Sub Branch', async () => {
try {
// แก้ไขสำนักงานใหญ่
await page.click("//div[@id='tree-enter-บริษัท โคโมโดะ จำกัด']/div[1]");
await page.waitForSelector('id=btn-kebab-action-สีลม1', {
state: 'visible',
});
await page.click('id=btn-kebab-action-สีลม1');
await page.waitForTimeout(1000);
await page.click('id=btn-kebab-edit-สีลม1');
await page.fill('id=input-name', 'สินสาทร');
await page.fill('id=input-name-en', 'Sinsathorn');
await page.click('id=btn-info-basic-save');
//ตรวจสอบรายละเอียดการแก้ไข
await page.click('id=btn-kebab-action-สินสาทร');
await page.click('id=btn-kebab-view-detail-สินสาทร');
//ตรวจสอบว่าได้ทำการแก้ไขถูกต้องหรือไม่
const detailEditName = await page.inputValue("//input[@value='สินสาทร']");
const detailEditNameEn = await page.inputValue(
"//input[@value='Sinsathorn']",
);
await expect(detailEditName).toBe('สินสาทร');
await expect(detailEditNameEn).toBe('Sinsathorn');
console.log('ตรวจสอบการแก้ไขข้อมูลสาขาถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(4000);
await page.click('id=btn-info-close');
});
test('Edit Visual Branch', async () => {
try {
// แก้ไขสำนักงานใหญ่
await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]");
await page.click('id=btn-kebab-action-บางรัก1');
await page.click('id=btn-kebab-edit-บางรัก1');
await page.fill('id=input-name', 'บางจาก');
await page.fill('id=input-name-en', 'Bangjak');
await page.click('id=btn-info-basic-save');
//ตรวจสอบรายละเอียดการแก้ไข
await page.click('id=btn-kebab-action-บางจาก');
await page.click('id=btn-kebab-view-detail-บางจาก');
//ตรวจสอบว่าได้ทำการแก้ไขถูกต้องหรือไม่
const detailEditName = await page.inputValue("//input[@value='บางจาก']");
const detailEditNameEn = await page.inputValue("//input[@value='Bangjak']");
await expect(detailEditName).toBe('บางจาก');
await expect(detailEditNameEn).toBe('Bangjak');
console.log('ตรวจสอบการแก้ไขข้อมูลสาขาเสมือนถูกต้อง');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
throw error;
}
await page.waitForTimeout(4000);
await page.click('id=btn-info-close');
});

View file

@ -1,49 +0,0 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Search Branch Management', async () => {
await page.click('id=menu-icon-branch-management');
await page.fill('id=input-Search', 'สีลม');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', 'สีลม1');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', 'สี');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', '1');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', '20/02');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', 'เชียงใหม่');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', 'เมือง');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', 'ช้างเผือก');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', 'ดำเนินการอยู่');
await page.waitForTimeout(2000);
await page.fill('id=input-Search', 'ปิดดำเนินการ');
await page.waitForTimeout(2000);
});

View file

@ -0,0 +1,229 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('ตรวจสอบการแสดงผลสถานะการใช้งาน เปิด/ปิด สำนักงานใหญ่', async () => {
try {
// คลิกเมนูเพื่อจัดการสาขา
await page.click('id=menu-icon-branch-management');
// แสดงสถานะที่ใช้งาน
// คลิกเพื่อเปิด dropdown
await page.click('id=field-select-status');
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อแสดงสถานะกำลังใช้งานอยู่
await page.click('id=field-select-status_1');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่ามีแต่สถานะใช้งานหรือไม่
const statusActive = await page.isVisible('id=field-select-status_1');
console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusActive); // เช็ค
expect(statusActive).toBe(false);
console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะกำลังใช้งานเท่านั้น');
// แสดงสถานะที่ไม่ใช้งาน
// คลิกเพื่อเปิด dropdown
await page.keyboard.press('Escape');
await page.click('id=field-select-status');
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อแสดงสถานะกำลังไม่ใช้งาน
await page.click('id=field-select-status_2');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่ามีแต่สถานะไม่ใช้งานหรือไม่
const statusInActive = await page.isVisible('id=field-select-status_1');
console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusInActive); // เช็ค
expect(statusActive).toBe(false);
console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะที่ไม่ใช้งาน');
// แสดงสถานะทั้งหมด
// คลิกเพื่อเปิด dropdown
await page.keyboard.press('Escape');
await page.click('id=field-select-status');
await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// คลิกเพื่อแสดงสถานะทั้งหมด
await page.click('id=field-select-status_0');
await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// ตรวจสอบว่าแสดงทุกสถานะหรือไม่
const statusAll = await page.isVisible('id=field-select-status_1');
console.log('สถานะทั้งหมด', statusAll); // เช็ค
expect(statusActive).toBe(false);
console.log('ตรวจสอบสถานะทั้งหมด');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
throw error;
}
await page.waitForTimeout(2000);
});
// test('ตรวจสอบการแสดงผลสถานะการใช้งาน เปิด/ปิด สาขา', async () => {
// try {
// // คลิกเข้าสู่สาขา
// await page.click("//div[@id='tree-enter-บริษัท โคโมโดะ จำกัด']/div[1]");
// // แสดงสถานะที่ใช้งาน
// // คลิกเพื่อเปิด dropdown
// await page.click('id=field-select-status');
// await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// // คลิกเพื่อแสดงสถานะกำลังใช้งานอยู่
// await page.click('id=field-select-status_1');
// await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// // ตรวจสอบว่ามีแต่สถานะใช้งานหรือไม่
// const statusActive = await page.isVisible('id=field-select-status_1');
// console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusActive); // เช็ค
// expect(statusActive).toBe(false);
// console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะกำลังใช้งานเท่านั้น');
// // แสดงสถานะที่ไม่ใช้งาน
// // คลิกเพื่อเปิด dropdown
// await page.keyboard.press('Escape');
// await page.click('id=field-select-status');
// await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// // คลิกเพื่อแสดงสถานะกำลังไม่ใช้งาน
// await page.click('id=field-select-status_2');
// await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// // ตรวจสอบว่ามีแต่สถานะไม่ใช้งานหรือไม่
// const statusInActive = await page.isVisible('id=field-select-status_1');
// console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusInActive); // เช็ค
// expect(statusActive).toBe(false);
// console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะที่ไม่ใช้งาน');
// // แสดงสถานะทั้งหมด
// // คลิกเพื่อเปิด dropdown
// await page.keyboard.press('Escape');
// await page.click('id=field-select-status');
// await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// // คลิกเพื่อแสดงสถานะทั้งหมด
// await page.click('id=field-select-status_0');
// await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// // ตรวจสอบว่าแสดงทุกสถานะหรือไม่
// const statusAll = await page.isVisible('id=field-select-status_1');
// console.log('สถานะทั้งหมด', statusAll); // เช็ค
// expect(statusActive).toBe(false);
// console.log('ตรวจสอบสถานะทั้งหมด');
// } catch (error) {
// console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
// throw error;
// }
// await page.waitForTimeout(2000);
// });
// test('ตรวจสอบการแสดงผลสถานะการใช้งาน เปิด/ปิด จุดรับบริการ', async () => {
// try {
// // คลิกเข้าสู่สาขาเสมือน
// await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]");
// // แสดงสถานะที่ใช้งาน
// // คลิกเพื่อเปิด dropdown
// await page.click('id=field-select-status');
// await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// // คลิกเพื่อแสดงสถานะกำลังใช้งานอยู่
// await page.click('id=field-select-status_1');
// await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// // ตรวจสอบว่ามีแต่สถานะใช้งานหรือไม่
// const statusActive = await page.isVisible('id=field-select-status_1');
// console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusActive); // เช็ค
// expect(statusActive).toBe(false);
// console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะกำลังใช้งานเท่านั้น');
// // แสดงสถานะที่ไม่ใช้งาน
// // คลิกเพื่อเปิด dropdown
// await page.keyboard.press('Escape');
// await page.click('id=field-select-status');
// await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// // คลิกเพื่อแสดงสถานะกำลังไม่ใช้งาน
// await page.click('id=field-select-status_2');
// await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// // ตรวจสอบว่ามีแต่สถานะไม่ใช้งานหรือไม่
// const statusInActive = await page.isVisible('id=field-select-status_1');
// console.log('มีเพียงสถานะการใช้งานเท่านั้น', statusInActive); // เช็ค
// expect(statusActive).toBe(false);
// console.log('ตรวจสอบสถานะการใช้งานมีแต่สถานะที่ไม่ใช้งาน');
// // แสดงสถานะทั้งหมด
// // คลิกเพื่อเปิด dropdown
// await page.keyboard.press('Escape');
// await page.click('id=field-select-status');
// await page.waitForTimeout(1000); // รอให้ dropdown เปิด
// // คลิกเพื่อแสดงสถานะทั้งหมด
// await page.click('id=field-select-status_0');
// await page.waitForTimeout(1000); // รอให้ UI อัปเดต
// // ตรวจสอบว่าแสดงทุกสถานะหรือไม่
// const statusAll = await page.isVisible('id=field-select-status_1');
// console.log('สถานะทั้งหมด', statusAll); // เช็ค
// expect(statusActive).toBe(false);
// console.log('ตรวจสอบสถานะทั้งหมด');
// } catch (error) {
// console.error('เกิดข้อผิดพลาดในการทดสอบ:', error);
// throw error;
// }
// await page.waitForTimeout(2000);
// });

View file

@ -0,0 +1,85 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import { Console, error, log } from 'console';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('Search Data Branch Management', async () => {
await page.click('id=menu-icon-branch-management');
try {
// กำหนดคำที่จะค้นหา
const searchDatas = [
'โคโมโดะ',
'คาโมมายด์',
'CM',
'CMO',
'00000',
'บางจาก',
'บางรัก',
'สีลม1',
];
for (const searchData of searchDatas) {
// พิมพ์คำที่ต้องการค้นหา
await page.fill('id=input-search', searchData); // ดึงคำมาจาก searchDatas
await page.waitForTimeout(2000);
// ดึงผลลัพฑ์การค้นหาทั้งหมด
const searchResults = page.locator("//table[@class='q-table']//tbody[1]");
const resultCount = await searchResults.count();
// ถ้าไม่มีผลลัพธ์ให้ข้ามคำถัดไป
if (resultCount === 0) {
console.error(`ไม่พบการค้นหา: '${searchData}', ข้ามไปคำถัดไป`);
continue; // ข้ามคำค้นหาคำถัดไป
}
// ดึงข้อความทั้งหมดของผลลัพธ์การค้นหา
const searchResultTexts = await searchResults.allTextContents();
console.log(`ผลลัพธ์ของการค้นหา '${searchData}'`, searchDatas);
// ตรวจสอบว่าผลลัพธ์ทั้งหมดมีคำที่ค้นหาหรือไม่
const allResultContainSearchData = searchResultTexts.every((result) =>
result.includes(searchData),
);
// ถ้าไม่พบคำค้นหา ให้แค่แจ้งเตือนและข้ามไปคำถัดไป
if (!allResultContainSearchData) {
console.error(
`\x1b[31mผลลัพธ์บางรายการไม่ตรงกับคำค้นหา: '${searchData}', ข้ามไปคำถัดไป\x1b[0m`,
);
continue; // ข้ามไปคำค้นหาถัดไป
}
expect(allResultContainSearchData).toBe(true);
console.log(`การค้นหา '${searchData}' และการแสดงผลสำเร็จ`);
}
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบการค้นหาหลายคำค้นหา', error);
throw error;
}
await page.waitForTimeout(2000);
});

View file

@ -0,0 +1,99 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import { Console, error, log } from 'console';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('ปิดการใช้งานสำนักงานใหญ่', async () => {
try {
await page.click('id=menu-icon-branch-management');
await page.click('id=btn-kebab-action-บริษัท คาโมมายด์ จำกัด');
await page.click('id=btn-kebab-status-บริษัท คาโมมายด์ จำกัด', {
force: true,
});
await page.click('id=btn-ok-dialog');
console.log('เปลี่ยนสถานะสำเร็จ');
await page.reload();
// รอ Update
await page.waitForTimeout(2000);
console.log('สถานะถูกเปลี่ยนแล้ว');
// ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ
const rowLocator = page.locator(
"//td[contains(.,'บริษัท คาโมมายด์ จำกัดCMM00000')]",
);
const backgroundColor = await rowLocator.evaluate(
(el) => window.getComputedStyle(el).backgroundColor,
);
// กำหนดสีหลัเปลี่ยนสถานะการใช้งาน
const expectedColor = 'rgb(249, 250, 252)';
// ตรวจสอบสีที่เปลี่ยนไป
expect(backgroundColor.trim()).toBe(expectedColor);
console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ');
throw error;
}
await page.waitForTimeout(2000);
});
test('เปิดการใช้งานสำนักงานใหญ่', async () => {
try {
await page.click('id=btn-kebab-action-บริษัท คาโมมายด์ จำกัด');
await page.click('id=btn-kebab-status-บริษัท คาโมมายด์ จำกัด', {
force: true,
});
await page.click('id=btn-ok-dialog');
console.log('เปลี่ยนสถานะสำเร็จ');
await page.reload();
// รอ Update
await page.waitForTimeout(2000);
console.log('สถานะถูกเปลี่ยนแล้ว');
// ตรวจสอบสีของแถวหลังจากทำการเปลี่ยนสถานะ
const rowLocator = page.locator(
"//td[contains(.,'บริษัท คาโมมายด์ จำกัดCMM00000')]",
);
const backgroundColor = await rowLocator.evaluate(
(el) => window.getComputedStyle(el).backgroundColor,
);
// กำหนดสีหลัเปลี่ยนสถานะการใช้งาน
const expectedColor = 'rgba(0, 0, 0, 0)';
// ตรวจสอบสีที่เปลี่ยนไป
expect(backgroundColor.trim()).toBe(expectedColor);
console.log('สีของแถวถูกเปลี่ยนเป็นของสถานะการใช้งาน');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการทดสอบ');
throw error;
}
await page.waitForTimeout(2000);
});

View file

@ -0,0 +1,217 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import { Console, error, log } from 'console';
import exp from 'constants';
import { it } from 'node:test';
let page: Page;
test.beforeAll(async ({ browser }) => {
page = await browser.newPage();
});
test.afterAll(async () => {
if (page !== undefined) {
await page.close();
}
});
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90: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');
});
test('ทดสอบการลบจัดการสาขา', async () => {
await page.click('id=menu-icon-branch-management');
// จำลองการสร้างสำนักงานใหญ่
await page.click('id=hq-add-btn');
await page.fill("(//input[@id='input-abbreviation'])[2]", 'TES');
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220284');
await page.fill("(//input[@id='input-name'])[2]", 'บริษัท จำลอง จำกัด');
await page.fill("(//input[@id='input-name-en'])[2]", 'JOMLONG');
await page.fill("(//input[@id='input-email'])[2]", 'JOM@support.com');
await page.fill("(//input[@id='input-telephone-no'])[2]", '022010100');
await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท');
await page.fill("(//input[@id='input-contact'])[2]", '0866224228');
await page.fill("(//input[@id='input-line-id'])[2]", 'como20');
await page.fill("(//input[@id='default-input-address'])[2]", '40/04');
await page.click("(//input[@id='default-select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-district'])[2]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-sub-district'])[2]");
await page.waitForTimeout(1000);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='default-input-address-en'])[2]", '40/04');
await page.click("(//input[@id='select-bankbook'])[3]");
await page.click('id=select-bankbook_4');
await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2022822624262');
await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน');
await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana');
await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]");
await page.waitForTimeout(2000);
await page.click('id=select-bankbook_0');
await page.click('id=btn-form-submit');
await page.waitForSelector('id=btn-ok-dialog');
await page.click('id=btn-ok-dialog');
// จำลองการสร้างสาขา
await page.click('id=create-sub-branch-btn-บริษัท จำลอง จำกัด');
await page.click("(//button[@type='submit'])[1]");
await page.fill("(//input[@id='input-tax-no'])[2]", '1260846220281');
await page.fill("(//input[@id='input-name'])[3]", 'สาขาจำลอง');
await page.fill("(//input[@id='input-name-en'])[2]", 'SAKAJOMLONG');
await page.fill(
"(//input[@aria-label='เลขที่ใบอนุญาต'])[2]",
'1228222822822',
);
await page.fill("(//input[@id='input-email'])[2]", 'test@support.com');
await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002');
await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอาท');
await page.fill("(//input[@id='input-contact'])[2]", '0822262228');
await page.fill("(//input[@id='input-line-id'])[2]", 'company');
await page.fill("(//input[@id='default-input-address-no'])[2]", '20/02');
await page.click("(//input[@id='default-select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-sub-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='default-input-address-en'])[2]", '20/02');
await page.click("(//input[@id='select-bankbook'])[3]");
await page.click('id=select-bankbook_1');
await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2282020021');
await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'เชียงใหม่');
await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana');
await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]");
await page.waitForTimeout(2000);
await page.click('id=select-bankbook_0');
await page.click('id=btn-form-submit');
// จำลองการสร้างสาขาเสมือน
await page.click('id=create-sub-branch-btn-บริษัท จำลอง จำกัด');
await page.click("(//button[@type='submit'])[2]");
await page.fill("(//input[@id='input-tax-no'])[2]", '2022826282642');
await page.fill("(//input[@id='input-name'])[2]", 'สาขาเสมือน');
await page.fill("(//input[@id='input-name-en'])[2]", 'VISUALBRANCH');
await page.fill("(//input[@id='input-email'])[2]", 'visual@local.co.th');
await page.fill("(//input[@id='input-telephone-no'])[2]", '022222002');
await page.fill("(//input[@id='input-contact-name'])[2]", 'คุณอุล');
await page.fill("(//input[@id='input-contact'])[2]", '0822622862');
await page.fill("(//input[@id='input-line-id'])[2]", 'cmmsupport');
await page.fill("(//input[@id='default-input-address'])[2]", '40/04');
await page.click("(//input[@id='default-select-province'])[2]");
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.click("(//input[@id='default-select-sub-district'])[2]");
await page.waitForTimeout(400);
await page.click("//div[@role='option']");
await page.fill("(//input[@id='default-input-address-en'])[2]", '40/04');
await page.click("(//input[@id='select-bankbook'])[3]");
await page.click('id=select-bankbook_2');
await page.fill("(//input[@aria-label='เลขบัญชี'])[2]", '2822642201');
await page.fill("(//input[@aria-label='สาขาธนาคาร'])[2]", 'ลำพูน');
await page.fill("(//input[@aria-label='ชื่อบัญชี'])[2]", 'Pongpon Kuntana');
await page.click("(//input[@aria-label='ประเภทบัญชี'])[2]");
await page.waitForTimeout(2000);
await page.click('id=select-bankbook_0');
await page.click('id=btn-form-submit');
// ลบสาขาและตรวจสอบการลบสาขา
try {
await page.click('id=btn-kebab-action-สาขาจำลอง');
await page.click('id=btn-kebab-delete-สาขาจำลอง');
// ยืนยันการลบ
await page.click('id=btn-ok-dialog');
await page.waitForTimeout(1000);
// ตรวจสอบการลบสาขา
const itemLocator = page.locator(
"//tr[contains(.,'1 สาขาจำลองTES0000112608462202810822262228คุณอาท20/02')]",
);
// ตรวจสอบว่าถูกลบออกจากระบบหรือไม่
await expect(itemLocator).toBeHidden();
console.log('ตรวจสอบข้อมูลการลบสาขาสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการลบสาขา', error);
throw error;
}
// ลบสาขาเสมือนและตรวจสอบการลบสาขาเสมือน
try {
await page.click('id=btn-kebab-action-สาขาเสมือน');
await page.click('id=btn-kebab-delete-สาขาเสมือน');
// ยืนยันการลบ
await page.click('id=btn-ok-dialog');
await page.waitForTimeout(1000);
// ตรวจสอบการลบสาขาเสมือน
const itemLocator = page.locator(
"//tr[contains(.,'2 สาขาเสมือนTES0000220228262826420822622862คุณอุล40/04')]",
);
// ตรวจสอบว่าถูกลบออกจากระบบหรือไม่
await expect(itemLocator).toBeHidden();
console.log('ตรวจสอบข้อมูลการลบสาขาเสมือนสำเร็จ');
} catch (error) {
console.error('เกิดข้อผิดพลาดในการลบสาขาเสมือน', error);
throw error;
}
// // ลบสำนักงานใหญ่และตรวจสอบการลบสำนักงานใหญ่
// await page.click("//div[@id='tree-enter-บริษัท จำลอง จำกัด']/div[1]");
// try {
// await page.click('id=btn-kebab-action-บริษัท จำลอง จำกัด');
// await page.click('id=btn-kebab-delete-บริษัท จำลอง จำกัด');
// // ยืนยันการลบ
// await page.click('id=btn-ok-dialog');
// await page.waitForTimeout(1000);
// // ตรวจสอบการลบสำนักงานใหญ่
// const itemLocator = page.locator(
// "//tr[contains(.,'9 บริษัท จำลอง จำกัดTES0000012608462202840866224228คุณอาท40/04')]",
// );
// // ตรวจสอบว่าถูกลบออกจากระบบหรือไม่
// await expect(itemLocator).toBeHidden();
// console.log('ตรวจสอบข้อมูลการลบสำนักงานใหญ่สำเร็จ');
// } catch (error) {
// console.error('เกิดข้อผิดพลาดในการลบสำนักงานใหญ่', error);
// throw error;
// }
await page.waitForTimeout(2000);
});