test : Update Script

This commit is contained in:
Linpiing 2024-09-26 11:05:54 +07:00
parent 9254c0183e
commit 297ff8c675
73 changed files with 2055 additions and 398 deletions

View file

@ -1,5 +1,6 @@
import { test, expect, Page } from '@playwright/test';
import { strictEqual } from 'assert';
import { log } from 'console';
let page: Page;
@ -15,7 +16,7 @@ test.afterAll(async () => {
test('Login', async () => {
// Login
await page.goto('http://192.168.1.90:20001/');
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');
@ -33,6 +34,11 @@ test('ทดสอบการเพิ่มกลุ่มสินค้า
await page.click('id=btn-add-product-group');
// กรอกข้อมูลกลุ่มสินค้าและบริการ
// await page.click("(//i[@aria-hidden='false'])[2]");
// await page.click("(//input[@id='input-source-nationality'])[2]");
// await page.click(
// "//span[normalize-space(text())='บริษัท คาโมมายด์ จำกัด']",
// );
await page.fill("(//input[@id='input-name'])[2]", 'ประกัน');
await page.fill("(//textarea[@id='input-detail'])[2]", 'รายละเอียดประกัน');
await page.fill("(//textarea[@id='input-remark'])[2]", 'หมายเหตุประกัน');
@ -66,50 +72,3 @@ test('ทดสอบการเพิ่มกลุ่มสินค้า
await page.waitForTimeout(2000);
});
test('ทดสอบการเพิ่มประเภท', async () => {
// เข้าสู่หน้าหลุ่มสินค้าและบริการ
await page.click("(//div[@id='tree-enter-ประกัน']//div)[1]");
try {
// เพิ่มกลุ่มสินค้าและบริการ
await page.click('id=btn-add');
await page.click('id=btn-add-service');
// กรอกข้อมูลประเภทส่วน "ข้อมูลประเภท"
await page.fill('id=input-service-code', 'MOU');
await page.fill('id=input-service-name', 'ประกันภัยแบบกลุ่ม');
await page.fill('id=input-service-description', 'รายละเอียดประภัยแบบกลุ่ม');
// เพิ่มคุณสมบัติส่วน "คุณสมบัติของประเภท"
await page.click('id=btn-capitalize');
// บันทึกการสร้างกลุ่มสินค้นและบริการ
await page.click('id=btn-form-submit');
// ตรวจสอบหลังทำการสร้างกลุ่มสินค้าและบริการ
const newProductAndServiceLocator = page.locator(
"//div[normalize-space(text())='ประกัน']",
);
await newProductAndServiceLocator.waitFor({ state: 'visible' });
// ดึงข้อความให้ตรงจาก XPath
const newProductAndServiceName =
await newProductAndServiceLocator.textContent();
// ตรวจสอบความถูกต้องหลังทำการสร้างกลุ่มสินค้าและบริการ
if (newProductAndServiceName !== null) {
const trimmedName = newProductAndServiceName.trim();
expect(trimmedName).toBe('ประกัน');
console.log('การตรวจสอบสำเร็จ : ถูกต้อง');
} else {
throw new Error('ไม่พบข้อมูลที่บันทึก');
}
} catch (error) {
console.error('เกิดข้อผิดการในการทดสอบ');
throw error;
}
await page.waitForTimeout(2000);
});