关于 testcafe 的窗口和定位问题

关于testcafe的问题请教一下,在运行后,唤起浏览器,浏览器的大小只有正常页面的左边一半大小,请问如何设置? 百度了很多方法都没有用。 由于测试的是登录页,通过查看元素功能查到了元素id,但是依然无法识别求大神解答,感谢!

我电脑分辨率是1920x1200,设置分辨率没有。再打开页面时设置也没有用。

testcafe chrome tongyi.js --window-size 1920x1200 --reporter html:report1.html

image.png

import { Selector } from 'testcafe';
const credentials = {
username: 'admin',
password: 'super_smart@123',
captcha: '1111' // 注意:这里假设验证码是静态的或已经通过某种方式获取
};

fixture('登录及连续对话测试')
.page('http://xxx:20201/login')
.before(async t => {
await t.resizeWindow(1920, 1080); // 在每个测试之前设置窗口大小
});

test('登录', async t => {
const username = Selector('#el-id-1002-3');
const password = Selector('#el-id-1002-4');
const captcha = Selector('#el-id-1002-5'); // 假设验证码的 ID 是这个
try {
console.log('检查用户名输入框是否存在...');
await t
.typeText(username, credentials.username);

console.log('检查密码输入框是否存在...');
await t
.typeText(password, credentials.password);

console.log('检查验证码输入框是否存在...');
await t
.typeText(captcha, credentials.captcha);

// 假设复选框的选择器是 '.el-checkbox' 下的 input 元素
const agreeCheckbox = Selector('.el-checkbox input[type="checkbox"]');
await t
.click(agreeCheckbox);

// 点击登录按钮
await t.click('#login-button'); // 假设登录按钮的 ID 是 '#login-button'

回帖
请输入回帖内容 ...