playwright-demo/tests/pfws/login.test.ts

41 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-08-02 09:50:12 +08:00
import { describe, it, expect } from '@jest/globals'
2021-05-27 15:25:25 +08:00
import { chromium } from "playwright";
2024-08-02 09:50:12 +08:00
describe('平台', function(){
2021-05-27 15:25:25 +08:00
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);
2024-08-02 09:50:12 +08:00
expect(await path.jsonValue()).not.toEqual('/user-login.html')
2021-05-27 15:25:25 +08:00
// ---------------------
2024-08-02 09:50:12 +08:00
await context.close();
await browser.close();
2021-05-27 15:25:25 +08:00
})
})