This commit is contained in:
xief
2021-05-27 15:25:25 +08:00
commit 941e8a1d8e
9 changed files with 1097 additions and 0 deletions

44
tests/mes/login.test.ts Normal file
View File

@@ -0,0 +1,44 @@
import { assert } from "chai";
import { chromium } from "playwright";
describe("mes登录", function () {
it('login', async function () {
const browser = await chromium.launch({
// headless: false
});
const context = await browser.newContext();
// Open new page
const page = await context.newPage();
// Go to http://sc.ihome6.cf/
await page.goto('http://sc.ihome6.cf/');
// Click [placeholder="账号"]
await page.click('[placeholder="账号"]');
// Fill [placeholder="账号"]
await page.fill('[placeholder="账号"]', 'dj');
// Press Tab
await page.press('[placeholder="账号"]', 'Tab');
// Fill [placeholder="密码"]
await page.fill('[placeholder="密码"]', '123456');
// Click button:has-text("登录")
await page.click('button:has-text("登录")');
await page.waitForTimeout(1000)
let path = await page.evaluateHandle(()=>window.location.hash.substr(1))
assert.equal('/dashboard',await path.jsonValue());
after(async function(){
await context.close();
await browser.close();
})
// ---------------------
})
})

42
tests/pfws/login.test.ts Normal file
View File

@@ -0,0 +1,42 @@
import { assert } from "chai";
import { chromium } from "playwright";
describe('平台', async function(){
it('登陆', async function(){
const browser = await chromium.launch({
// headless: false
});
const context = await browser.newContext();
// Open new page
const page = await context.newPage();
// Go to http://ihome6.cf/
await page.goto('http://ihome6.cf/');
// Click text=买家中心
await page.click('text=买家中心');
// assert.equal(page.url(), 'http://ihome6.cf/user-login.html');
// Click [placeholder="请输入用户名/手机号码"]
await page.click('[placeholder="请输入用户名/手机号码"]');
// Fill [placeholder="请输入用户名/手机号码"]
await page.fill('[placeholder="请输入用户名/手机号码"]', 'yangxb');
// Press Tab
await page.press('[placeholder="请输入用户名/手机号码"]', 'Tab');
// Fill [placeholder="请输入密码"]
await page.fill('[placeholder="请输入密码"]', '123456');
// Click button:has-text("登录")
await page.click('button:has-text("登录")');
let path = await page.evaluateHandle(()=>window.location.pathname);
assert.notEqual('/user-login.html',await path.jsonValue());
// ---------------------
after(async () => {
await context.close();
await browser.close();
})
})
})