Пожалуйста, посмотрите на структуру ниже. Есть ли способ заставить 'Пример 1' работать? Идея состоит в том, чтобы не хранить 'css строку селектора' в классе 'test'.
MyAccount. js
import { Selector} from "testcafe";
export class MyAccount {
constructor() {
this.box = {
item_1: Selector("#item01");
item_2: Selector("#item02");
}
}
}
clientFunctions. js
import { ClientFunction } from 'testcafe';
export const scrollInto = ClientFunction((selector) => {
var element = window.document.querySelector(selector);
element.scrollIntoView();
});
ПРИМЕР 1. (СБОЙ)
import { MyAccount } from "../MyAccount";
import { scrollInto } from "../clientFunctions";
const myAccount = new MyAccount();
fixture("Feature A").page(process.env.url);
test("Test 01", async t => {
await scrollInto(myAccount.box.item_1);
});
ПРИМЕР 2. (ПРОЙДЕН)
import { MyAccount } from "../MyAccount";
import { scrollInto } from "../clientFunctions";
const myAccount = new MyAccount();
fixture("Feature A").page(process.env.url);
test("Test 01", async t => {
await scrollInto("#item01");
});