index.test.js 1.9 KB
Newer Older
study夏羽's avatar
study夏羽 已提交
1 2 3 4 5 6
// jest官方文档: https://www.jestjs.cn/
// uniapp自动化测试教程: https://uniapp.dcloud.io/collocation/auto/quick-start
describe('pages/ucenter/login-page/index/index.vue', () => {

	let page
	beforeAll(async () => {
study夏羽's avatar
study夏羽 已提交
7 8 9 10 11 12
		try {
			page = await program.navigateTo('/pages/ucenter/login-page/index/index?type=smsCode')
			console.log("page: ",page);
		} catch (e) {
			console.log("e: ",e);
		}
study夏羽's avatar
study夏羽 已提交
13 14 15 16 17
		await page.waitFor(1000)
		console.log("await program.pageStack(): ",await program.pageStack());
	})


study夏羽's avatar
study夏羽 已提交
18
	it('smsCode-login', async () => {
study夏羽's avatar
study夏羽 已提交
19 20 21 22 23 24 25
		const image = await program.screenshot({
			path: "static/screenshot/login-index.png" // 默认项目根目录
		})

		const perPage = await page.$('.content')
		// console.log("perPage: ", perPage);
		const getTitle = await perPage.$('.title')
study夏羽's avatar
study夏羽 已提交
26 27 28 29 30 31
		console.log("getTitle: ",getTitle);
		// console.log(await getTitle.text());
		
		
		console.log("await program.currentPage(): ",await program.currentPage());
		
study夏羽's avatar
study夏羽 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44

		if ((await program.currentPage()).path == 'pages/ucenter/login-page/index/index') {
			expect(await getTitle.text()).toBe('登录后即可展示自己')
			
			const setInput = await page.setData({
				"phone": '17769516019',
				"agree": true,
				// "type":"smsCode"
			})
			await page.waitFor(300)
			console.log(await page.data('phone'), "phone----------");
			console.log(await page.data('agree'), "agree-----------");
			console.log(await page.data('type'), "type----------");
study夏羽's avatar
study夏羽 已提交
45 46 47 48 49 50 51 52 53 54 55
			
			const agreeTrue = await page.waitFor(async () => {
				return await page.data('agree')
			})
			console.log("agreeTrue: ", agreeTrue);
			
			await page.callMethod('sendShortMsg')
			await page.waitFor(300)
			// console.log((await program.currentPage()).path);
			//pages/ucenter/login-page/phone-code/phone-code
			
study夏羽's avatar
study夏羽 已提交
56 57
		}
		
study夏羽's avatar
study夏羽 已提交
58 59 60 61
		if ((await program.currentPage()).path == 'pages/ucenter/login-page/pwd-login/pwd-login') {
			expect(await getTitle.text()).toBe('用户名密码登录')
			
		}
study夏羽's avatar
study夏羽 已提交
62 63 64

	})
})