update test
This commit is contained in:
parent
f3982978fa
commit
c4bdd18deb
123 changed files with 12136 additions and 5001 deletions
|
|
@ -0,0 +1,69 @@
|
|||
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-productService');
|
||||
await page.click('id=sub-menu-productService');
|
||||
|
||||
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-add');
|
||||
await page.waitForSelector('id=btn-info-basic-save');
|
||||
await page.click('id=btn-info-basic-save');
|
||||
|
||||
const nameProductGroupandService = await page.locator(
|
||||
"//div[@class='q-field__messages col']//div[1]",
|
||||
);
|
||||
|
||||
await expect(nameProductGroupandService).toHaveText(
|
||||
'จำเป็นต้องกรอกข้อมูลนี้',
|
||||
);
|
||||
console.log('ระบบทำการแจ้งเตือนถูกต้อง');
|
||||
} catch (error) {
|
||||
console.log('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue