我正在使用testcafe在电子商务页面中运行一些测试,但是随机弹出会破坏该测试。当它出现在窗口中时,Testcafe无法单击下一个选择器并继续进行测试,然后失败。
目前,我正在使用.js文件来保存选择器,例如:
import { Selector } from 'testcafe';
export default class Checkout {
constructor () {
//address
this.addressName = Selector('input#CC-checkoutCepAddressBook-sfirstname');
this.addressLastname = Selector('input#CC-checkoutCepAddressBook-slastname');
//Rest of selectors...
}
Run Code Online (Sandbox Code Playgroud)
然后,将它们导入另一个.js并声明测试,例如函数:
import { ClientFunction } from 'testcafe';
import { Selector } from 'testcafe';
import Fixture from '../../../DesktopModel/Chrome/fixture.js';
import Home from '../../../DesktopModel/Chrome/home.js';
import Cart from '../../../DesktopModel/Chrome/cart.js';
...
const fixtureUrlBase = new Fixture();
const home = new Home();
const pdp = new Pdp();
const cart = new Cart();
...
export async function checkoutLoggedBoleto(t) {
await …Run Code Online (Sandbox Code Playgroud) testing automated-tests conditional-statements e2e-testing testcafe