This repository has been archived on 2025-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
playwright-demo/tests/zhb/pom/h5LoginPage.js
rsgltzyd db0603dcfd
Some checks failed
Playwright Tests / test (push) Has been cancelled
init
2024-11-07 22:00:35 +08:00

26 lines
932 B
JavaScript

const { processAndRecognizeCaptcha } = require('../../utils/helper');
class H5LoginPage {
constructor(page) {
this.page = page;
this.$account = this.page.getByPlaceholder('此处请输入手机号');
this.$GraphCode = this.page.getByRole('textbox', { name: '请输入图形验证码' });
this.$SmsCode = this.page.getByRole('textbox', { name: '验证码', exact: true });
this.$loginBtn = this.page.locator('uni-button').filter({ hasText: /^登录$/ });
}
sendSmsCode = async (account) => {
const imagePath = '.images/captcha.png';
const outputImagePath = '.images/output-captcha.png';
await this.$account.fill(account);
const $graph = this.page.getByRole('img', { name: '图形验证码' });
await $graph.waitFor();
await $graph.screenshot({ path: imagePath });
return await processAndRecognizeCaptcha(imagePath, outputImagePath);
};
}
module.exports = { H5LoginPage };