update test
This commit is contained in:
parent
f3982978fa
commit
c4bdd18deb
123 changed files with 12136 additions and 5001 deletions
|
|
@ -0,0 +1,78 @@
|
|||
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-customer');
|
||||
await page.click('id=sub-menu-customer');
|
||||
await page.waitForTimeout(2000);
|
||||
|
||||
isLoginSuccessful = true;
|
||||
console.log('Login สำเร็จ');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการ Login', error);
|
||||
isLoginSuccessful = false;
|
||||
}
|
||||
}
|
||||
|
||||
test('Login', async () => {
|
||||
await login(page);
|
||||
});
|
||||
|
||||
test('Edit Naturalperson', async () => {
|
||||
if (!isLoginSuccessful) {
|
||||
await login(page);
|
||||
}
|
||||
|
||||
try {
|
||||
await page.click('id=btn-kebab-action-สุรวัฒน์');
|
||||
await page.waitForSelector('id=btn-kebab-edit-สุรวัฒน์');
|
||||
await page.click('id=btn-kebab-edit-สุรวัฒน์');
|
||||
|
||||
// แก้ไขนายจ้างบุคคลธรรมดา
|
||||
await page.fill("(//input[@id='info-input-first-name'])[1]", 'ธนพล');
|
||||
await page.fill("(//input[@id='info-input-last-name'])[1]", 'รุ่งเรือง');
|
||||
await page.fill("(//input[@id='info-input-first-name'])[3]", 'Thanapol');
|
||||
await page.fill("(//input[@id='info-input-last-name'])[2]", 'Rungreung');
|
||||
await page.waitForSelector("//button[@type='submit']");
|
||||
await page.click("//button[@type='submit']");
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitForSelector('id=btn-info-close');
|
||||
await page.click('id=btn-info-close');
|
||||
const nameEditCheck = await page.locator(
|
||||
"//tr[contains(.,'นาย ธนพล รุ่งเรือง') and contains(.,'--')]",
|
||||
);
|
||||
|
||||
await expect(nameEditCheck).toContainText('ธนพล รุ่งเรือง');
|
||||
await expect(nameEditCheck).toContainText('--');
|
||||
} catch (error) {
|
||||
console.error('เกิดข้อผิดพลาดในการทดสอบ', error);
|
||||
isLoginSuccessful = false;
|
||||
throw error;
|
||||
}
|
||||
await page.waitForTimeout(2000);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue