update test
This commit is contained in:
parent
f3982978fa
commit
c4bdd18deb
123 changed files with 12136 additions and 5001 deletions
|
|
@ -0,0 +1,227 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import path from 'path';
|
||||
import { off } from 'process';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
|
||||
// ถ้าทั้งหมดสำเร็จ
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login');
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Branch Managenment', async () => {
|
||||
// ถ้ายังไม่ได้ Login ให้ทำการ Login
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
// เข้าสู่เมนูสาขา
|
||||
await page.click('id=menu.manage');
|
||||
await page.waitForSelector('id=sub-menu-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
|
||||
// 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'])[2]", 'บริษัท คาโมมายด์ จำกัด');
|
||||
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-info-basic-save');
|
||||
|
||||
await page.waitForSelector('id=btn-ok-dialog');
|
||||
await page.click('id=btn-ok-dialog');
|
||||
await page.click('id=btn-form-close');
|
||||
|
||||
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('Create Branch Managenment Second', async () => {
|
||||
// ถ้ายังไม่ได้ Login ให้ทำการ Login
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
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'])[2]", 'บริษัท โคโม่ จำกัด');
|
||||
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-info-basic-save');
|
||||
|
||||
await page.waitForSelector('id=btn-ok-dialog');
|
||||
await page.click('id=btn-ok-dialog');
|
||||
await page.click('id=btn-form-close');
|
||||
|
||||
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
|
@ -0,0 +1,206 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { log } from 'console';
|
||||
import exp from 'constants';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Branch Management - ไม่มีการกรอกข้อมูล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
// เปลี่ยนภาษา
|
||||
await page.click('id=btn-change-language');
|
||||
await page.waitForSelector('id=btn-change-language-eng');
|
||||
await page.click('id=btn-change-language-eng');
|
||||
|
||||
await page.click('id=hq-add-btn');
|
||||
await page.click('id=btn-info-basic-save');
|
||||
|
||||
const expectedErrors = [
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[1]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[2]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[3]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[4]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[5]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[6]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[7]",
|
||||
message: 'Please select Province.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[8]",
|
||||
message: 'Please select District.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[9]",
|
||||
message: 'Please select Sub-district.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[10]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
];
|
||||
|
||||
for (const error of expectedErrors) {
|
||||
const locator = page.locator(error.locator);
|
||||
await expect(locator).toHaveText(error.message);
|
||||
}
|
||||
console.log('ระบบตรวจสอบการแจ้งเตือนแล้ว');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
console.log('การตรวจสอบ Validation ถูกต้อง');
|
||||
});
|
||||
|
||||
test('Create Branch Managenment - กรณีที่กรอกชื่อย่อที่ไม่ใช่ภาษาอังกฤษ', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=hq-add-btn');
|
||||
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(
|
||||
'Invalid value. Only _ letters and number are allowed',
|
||||
{
|
||||
timeout: 2000,
|
||||
},
|
||||
);
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่ไม่ใช่ภาษาอังกฤษถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Branch Management - กรอกเลขนิติบุคคลในกรณีที่กรอกไม่ครบจำนวน 13 หลัก', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=hq-add-btn');
|
||||
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(
|
||||
'Invalid value. Please enter 13 character',
|
||||
{
|
||||
timeout: 2000,
|
||||
},
|
||||
);
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Branch Management - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=hq-add-btn');
|
||||
await page.fill("(//input[@id='input-email'])[2]", '123');
|
||||
const emailError = page.locator(
|
||||
// ตรวจสอบการแสดง Validation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ
|
||||
"(//div[@class='q-field__messages col']//div)[2]",
|
||||
);
|
||||
|
||||
await expect(emailError).toHaveText('Invalid value.', {
|
||||
timeout: 2000,
|
||||
});
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
|
@ -0,0 +1,210 @@
|
|||
import { test, expect, Page, errors } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { log } from 'console';
|
||||
import exp from 'constants';
|
||||
import { errorMonitor } from 'stream';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
|
||||
// ถ้าขั้นตอนสำเร็จ
|
||||
isLoginSuccessful = true;
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Branch Management - ไม่มีการกรอกข้อมูล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
// เข้าสู่เมนูสาขา
|
||||
await page.click('id=menu.manage');
|
||||
await page.waitForSelector('id=sub-menu-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
|
||||
await page.click('id=hq-add-btn');
|
||||
await page.click('id=btn-info-basic-save');
|
||||
|
||||
const exceptError = [
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[1]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[2]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[3]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[4]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[5]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[6]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[7]",
|
||||
message: 'โปรดเลือกจังหวัด',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[8]",
|
||||
message: 'โปรดเลือกเขต/อำเภอ',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[9]",
|
||||
message: 'โปรดเลือกแขวง/ตำบล',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[10]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
];
|
||||
|
||||
for (const error of exceptError) {
|
||||
const locator = page.locator(error.locator);
|
||||
await expect(locator).toHaveText(error.message);
|
||||
}
|
||||
console.log('ระบบตรวจสอบการแจ้งเตือนแล้ว');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
console.log('การตรวจสอบ Validation ถูกต้อง');
|
||||
});
|
||||
|
||||
test('Create Branch Managenment - กรณีที่กรอกชื่อย่อที่ไม่ใช่ภาษาอังกฤษ', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=hq-add-btn');
|
||||
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 แจ้งเตือนในกรณีที่ไม่ใช่ภาษาอังกฤษถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Branch Management - กรอกเลขนิติบุคคลในกรณีที่กรอกไม่ครบจำนวน 13 หลัก', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=hq-add-btn');
|
||||
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 หลัก',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Branch Management - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=hq-add-btn');
|
||||
await page.fill("(//input[@id='input-email'])[2]", '123');
|
||||
const emailError = page.locator(
|
||||
// ตรวจสอบการแสดง Validation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ
|
||||
"(//div[@class='q-field__messages col']//div)[2]",
|
||||
);
|
||||
|
||||
await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง', {
|
||||
timeout: 2000,
|
||||
});
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ถูกรูปแบบ',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Sub Branch Managenment', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
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'])[2]", `สีลม${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-info-basic-save');
|
||||
await page.click('id=btn-form-close');
|
||||
}
|
||||
|
||||
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
|
@ -0,0 +1,207 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { log } from 'console';
|
||||
import { fstat } from 'fs';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
//ถ้าขั้นตอนสำเร็จ
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - ในกรณีที่ไม่กรอกข้อมูล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
// เปลี่ยนภาษา
|
||||
await page.click('id=btn-change-language');
|
||||
await page.waitForSelector('id=btn-change-language-eng');
|
||||
await page.click('id=btn-change-language-eng');
|
||||
|
||||
await page.click('id=create-sub-branch-btn-COMO');
|
||||
await page.click("(//button[@type='submit'])[1]");
|
||||
await page.click('id=btn-info-basic-save');
|
||||
|
||||
const expectedErrors = [
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[1]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[2]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[3]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[4]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[5]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[6]",
|
||||
message: 'Please select Province.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[7]",
|
||||
message: 'Please select District.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[8]",
|
||||
message: 'Please select District.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[9]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
];
|
||||
|
||||
for (const error of expectedErrors) {
|
||||
const locator = page.locator(error.locator);
|
||||
await expect(locator).toHaveText(error.message);
|
||||
}
|
||||
|
||||
console.log('การตรวจสอบ Validation ถูกต้อง');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=create-sub-branch-btn-COMO');
|
||||
|
||||
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(
|
||||
'Invalid value. Please enter 13 character',
|
||||
);
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=create-sub-branch-btn-COMO');
|
||||
|
||||
await page.click("(//button[@type='submit'])[1]");
|
||||
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('Invalid value.');
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - กรอกชื่อสาขาในกรณีที่ไม่ใช่ภาษาอังกฤษ', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=create-sub-branch-btn-COMO');
|
||||
|
||||
await page.click("(//button[@type='submit'])[1]");
|
||||
await page.fill("(//input[@id='input-name-en'])[2]", 'ทดสอบ');
|
||||
|
||||
// ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก
|
||||
const emailError = page.locator(
|
||||
"(//div[@class='q-field__messages col']//div)[2]",
|
||||
);
|
||||
|
||||
await expect(emailError).toHaveText('Only letters are allowed');
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - ในกรณีที่ไม่กรอกข้อมูล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด');
|
||||
await page.click("(//button[@type='submit'])[1]");
|
||||
await page.click('id=btn-info-basic-save');
|
||||
|
||||
const expectedErrors = [
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[1]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[2]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[3]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[4]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[5]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[6]",
|
||||
message: 'โปรดเลือกจังหวัด',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[7]",
|
||||
message: 'โปรดเลือกเขต/อำเภอ',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[8]",
|
||||
message: 'โปรดเลือกแขวง/ตำบล',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[9]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
];
|
||||
|
||||
for (const error of expectedErrors) {
|
||||
const locator = page.locator(error.locator);
|
||||
await expect(locator).toHaveText(error.message);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
console.log('การตรวจสอบ Validation ถูกต้อง');
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
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 หลัก',
|
||||
);
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
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');
|
||||
|
||||
// ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก
|
||||
const emailError = page.locator(
|
||||
"(//div[@class='q-field__messages col']//div)[2]",
|
||||
);
|
||||
|
||||
await expect(emailError).toHaveText('ข้อมูลไม่ถูกต้อง');
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Sub-Branch Managenment - กรอกชื่อสาขาในกรณีที่ไม่ใช่ภาษาอังกฤษ', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=create-sub-branch-btn-บริษัท โคโม่ จำกัด');
|
||||
await page.click("(//button[@type='submit'])[1]");
|
||||
await page.fill("(//input[@id='input-name-en'])[2]", 'ทดสอบ');
|
||||
|
||||
// ตรวจสอบการแจ้งเตือนของทะเบียนนิติบุคคลเลขที่ในกรณีที่กรอกข้อมูลไม่ครบ 13 หลัก
|
||||
const emailError = page.locator(
|
||||
"(//div[@class='q-field__messages col']//div)[2]",
|
||||
);
|
||||
|
||||
await expect(emailError).toHaveText(
|
||||
'โปรดใช้เฉพาะตัวอักษรภาษาอังกฤษเท่านั้น',
|
||||
);
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login');
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Service Point Managenment', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
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'])[2]", `บางรัก${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-info-basic-save');
|
||||
await page.click('id=btn-form-close');
|
||||
}
|
||||
|
||||
// ตรวจสอบความถูกต้องหลังจากทำการบันทึกสร้างสำนักงานใหญ่
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { exec } from 'child_process';
|
||||
import { error } from 'console';
|
||||
import exp from 'constants';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Service Point - ในกรณีที่ไม่กรอกข้อมูล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
// เปลี่ยนภาษา
|
||||
await page.click('id=btn-change-language');
|
||||
await page.waitForSelector('id=btn-change-language-eng');
|
||||
await page.click('id=btn-change-language-eng');
|
||||
|
||||
await page.click('id=create-sub-branch-btn-CHAMOMIND');
|
||||
await page.click("(//button[@type='submit'])[2]");
|
||||
await page.click('id=btn-info-basic-save');
|
||||
|
||||
const expectedErrors = [
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[1]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[2]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[3]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[4]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[5]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[6]",
|
||||
message: 'Please select Province.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[7]",
|
||||
message: 'Please select District.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[8]",
|
||||
message: 'Please select Sub-district.',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[9]",
|
||||
message: 'This field is required.',
|
||||
},
|
||||
];
|
||||
|
||||
for (const error of expectedErrors) {
|
||||
const locator = page.locator(error.locator);
|
||||
await expect(locator).toHaveText(error.message);
|
||||
}
|
||||
|
||||
console.log('การตรวจสอบ Validation ถูกต้อง');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Service Point - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=create-sub-branch-btn-CHAMOMIND');
|
||||
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(
|
||||
'Invalid value. Please enter 13 character',
|
||||
);
|
||||
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Service Point - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.reload();
|
||||
await page.click('id=create-sub-branch-btn-CHAMOMIND');
|
||||
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('Invalid value.');
|
||||
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
|
@ -0,0 +1,167 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { exec } from 'child_process';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Create Service Point - ในกรณีที่ไม่กรอกข้อมูล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.click('id=create-sub-branch-btn-บริษัท คาโมมายด์ จำกัด');
|
||||
await page.click("(//button[@type='submit'])[2]");
|
||||
await page.click('id=btn-info-basic-save');
|
||||
|
||||
const expectedErrors = [
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[1]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[2]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[3]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[4]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[5]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[6]",
|
||||
message: 'โปรดเลือกจังหวัด',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[7]",
|
||||
message: 'โปรดเลือกเขต/อำเภอ',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[8]",
|
||||
message: 'โปรดเลือกแขวง/ตำบล',
|
||||
},
|
||||
{
|
||||
locator: "(//div[@class='q-field__messages col']//div)[9]",
|
||||
message: 'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
},
|
||||
];
|
||||
|
||||
for (const error of expectedErrors) {
|
||||
const locator = page.locator(error.locator);
|
||||
await expect(locator).toHaveText(error.message);
|
||||
}
|
||||
|
||||
console.log('การตรวจสอบ Validation ถูกต้อง');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Service Point - ในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลัก', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
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 หลัก',
|
||||
);
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกทะเบียนนิติบุคคลเลขที่ไม่ครบ 13 หลักถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
||||
test('Create Service Point - กรอกอีเมลในกรณีที่ไม่ตรงรูปแบบอีเมล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
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('ข้อมูลไม่ถูกต้อง');
|
||||
console.log(
|
||||
'ตรวจสอบการแสดง Vidation แจ้งเตือนในกรณีที่กรอกอีเมลไม่ตรงรูปแบบถูกต้อง',
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-form-close');
|
||||
});
|
||||
|
|
@ -0,0 +1,427 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { log } from 'console';
|
||||
import { sign } from 'crypto';
|
||||
import { watchFile } from 'fs';
|
||||
import { waitForDebugger } from 'inspector';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลลำดับที่', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
// คลิกเพื่อเปิด 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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลชื่อ', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลทะเบียนนิติบุคคล', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลเบอร์โทรสำนักงาน', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลติดต่อ', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('ตรวจสอบการแสดงผลฟิลด์แสดงผลที่อยู่', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { log } from 'console';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('ทดสอบการดูรายละเอียดสำนักงานใหญ่', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-info-close');
|
||||
});
|
||||
|
||||
test('ทดสอบการดูรายละเอียดสาขา', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-info-close');
|
||||
});
|
||||
|
||||
test('ทดสอบการดูรายละเอียดจุดรับบริการ', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-info-close');
|
||||
});
|
||||
|
||||
test('ทดสอบการดูรายละเอียดสำนักงานใหญ่ในรูปแบบการ์ด', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
await page.reload();
|
||||
|
||||
await page.click("//button[@aria-pressed='false']");
|
||||
await page.waitForTimeout(2000);
|
||||
try {
|
||||
const nameBrnach = page.locator(
|
||||
"//b[normalize-space(text())='บริษัท คาโมมายด์ จำกัด']",
|
||||
);
|
||||
const legalPerson = page.locator(
|
||||
"(//div[text()='ทะเบียนนิติบุคคล']/following-sibling::div)[1]",
|
||||
);
|
||||
const cellPhone = page.locator(
|
||||
"(//div[text()='เบอร์โทรสำนักงาน']/following-sibling::div)[1]",
|
||||
);
|
||||
const contactName = page.locator("//div[normalize-space(text())='คุณต่อ']");
|
||||
const address = page.locator(
|
||||
"//div[normalize-space(text())='20/02 หมู่ 1, พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200']",
|
||||
);
|
||||
|
||||
await expect(nameBrnach).toHaveText('บริษัท คาโมมายด์ จำกัด');
|
||||
await expect(legalPerson).toHaveText('1260846220284');
|
||||
await expect(cellPhone).toHaveText('0866224228');
|
||||
await expect(contactName).toHaveText('คุณต่อ');
|
||||
await expect(address).toHaveText(
|
||||
'20/02 หมู่ 1, พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200',
|
||||
);
|
||||
|
||||
console.log('ตรวจสอบข้อมูลถูกต้อง');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
});
|
||||
|
||||
test('ทดสอบการดูรายละเอียดสาขาในรูปแบบการ์ด', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.click("//div[@id='tree-enter-บริษัท คาโมมายด์ จำกัด']/div[1]");
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
const legalPerson = page.locator(
|
||||
"(//div[text()='ทะเบียนนิติบุคคล']/following-sibling::div)[1]",
|
||||
);
|
||||
const contactName = page.locator(
|
||||
"(//div[text()='ติดต่อ']/following-sibling::div)[1]",
|
||||
);
|
||||
const address = page.locator(
|
||||
"//div[normalize-space(text())='40/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200']",
|
||||
);
|
||||
|
||||
await expect(legalPerson).toHaveText('2022826282641');
|
||||
await expect(contactName).toHaveText('คุณอุล');
|
||||
await expect(address).toHaveText(
|
||||
'40/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200',
|
||||
);
|
||||
|
||||
console.log('ตรวจสอบข้อมูลถูกต้อง');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
});
|
||||
|
||||
test('ทดสอบการดูรายละเอียดจุดรับบริการในรูปแบบการ์ด', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.click("(//div[@id='tree-enter-บริษัท โคโม่ จำกัด']//div)[1]");
|
||||
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
const legalPerson = page.locator(
|
||||
"(//div[text()='ทะเบียนนิติบุคคล']/following-sibling::div)[1]",
|
||||
);
|
||||
const contactName = page.locator(
|
||||
"(//div[text()='ติดต่อ']/following-sibling::div)[1]",
|
||||
);
|
||||
const address = page.locator(
|
||||
"//div[normalize-space(text())='20/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200']",
|
||||
);
|
||||
|
||||
await expect(legalPerson).toHaveText('1260846220281');
|
||||
await expect(contactName).toHaveText('คุณอาท');
|
||||
await expect(address).toHaveText(
|
||||
'20/01 พระบรมมหาราชวัง, พระนคร, กรุงเทพมหานคร 10200',
|
||||
);
|
||||
|
||||
console.log('ตรวจสอบข้อมูลถูกต้อง');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
});
|
||||
|
|
@ -0,0 +1,160 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import exp from 'constants';
|
||||
import { sign } from 'crypto';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Edit Headquter Branch', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
// แก้ไขสำนักงานใหญ่
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-info-close');
|
||||
});
|
||||
|
||||
test('Edit Sub Branch', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-info-close');
|
||||
});
|
||||
|
||||
test('Edit Visual Branch', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
|
||||
await page.waitForTimeout(4000);
|
||||
await page.click('id=btn-info-close');
|
||||
});
|
||||
|
|
@ -0,0 +1,249 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login');
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('ตรวจสอบการแสดงผลสถานะการใช้งาน เปิด/ปิด สำนักงานใหญ่', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
try {
|
||||
// แสดงสถานะที่ใช้งาน
|
||||
// คลิกเพื่อเปิด 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);
|
||||
isLoginSuccessful = false;
|
||||
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);
|
||||
// });
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { Console, error, log } from 'console';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Search Data Branch Management', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
|
@ -0,0 +1,127 @@
|
|||
import { test, expect, Page } from '@playwright/test';
|
||||
import { strictEqual } from 'assert';
|
||||
import { Console, error, log } from 'console';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('ปิดการใช้งานสำนักงานใหญ่', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
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 = 'rgb(249, 250, 252)';
|
||||
|
||||
// ตรวจสอบสีที่เปลี่ยนไป
|
||||
expect(backgroundColor.trim()).toBe(expectedColor);
|
||||
console.log('สีของแถวถูกเปลี่ยนเป็นสีเทาอ่อน');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ');
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
||||
test('เปิดการใช้งานสำนักงานใหญ่', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
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('เกิดข้อผิดพลาดในการทดสอบ');
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
|
|
@ -0,0 +1,247 @@
|
|||
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';
|
||||
import { prependOnceListener } from 'process';
|
||||
|
||||
let page: Page;
|
||||
let isLoginSuccessful = false;
|
||||
|
||||
test.beforeAll(async ({ browser }) => {
|
||||
page = await browser.newPage();
|
||||
});
|
||||
|
||||
test.afterAll(async () => {
|
||||
if (page !== undefined) {
|
||||
await page.close();
|
||||
}
|
||||
});
|
||||
|
||||
async function login(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-branch');
|
||||
await page.click('id=sub-menu-branch');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('ระบบทำการ Login');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('ทดสอบการลบจัดการสาขา', async () => {
|
||||
// จำลองการสร้างสำนักงานใหญ่
|
||||
|
||||
// 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-license-number'])[2]", '2938227328292');
|
||||
// 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-no'])[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-info-basic-save');
|
||||
|
||||
// await page.waitForSelector('id=btn-ok-dialog');
|
||||
// await page.click('id=btn-ok-dialog');
|
||||
// await page.click('id=btn-form-close');
|
||||
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
// จำลองการสร้างสาขา
|
||||
try {
|
||||
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'])[2]", 'สาขาจำลอง');
|
||||
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-info-basic-save');
|
||||
await page.click('id=btn-form-close');
|
||||
|
||||
// จำลองการสร้างสาขาเสมือน
|
||||
|
||||
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[@aria-label='เลขที่ใบอนุญาต'])[2]",
|
||||
'1228222822822',
|
||||
);
|
||||
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-no'])[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-info-basic-save');
|
||||
await page.click('id=btn-form-close');
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
// ลบสาขาและตรวจสอบการลบสาขา
|
||||
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);
|
||||
isLoginSuccessful = false;
|
||||
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);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue