本文整理匯總了TypeScript中@theintern/leadfoot/Command.findByCssSelector函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript findByCssSelector函數的具體用法?TypeScript findByCssSelector怎麽用?TypeScript findByCssSelector使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了findByCssSelector函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: resize
function resize(command: Command<Element | void>, x: number, y: number): Command<void> {
return command
.findByCssSelector(`.${css.divider}`)
.moveMouseTo()
.pressMouseButton(0)
.moveMouseTo(x, y)
.releaseMouseButton(0)
.sleep(DELAY)
.end();
}
示例2: testResizes
function testResizes(command: Command<Element | void>, resizes: Coord[], expected: CoordTest[]) {
assert.strictEqual(resizes.length, expected.length, 'Resizes array should match expected array.');
let currentX: number;
let currentY: number;
command = command
.findByCssSelector(`.${css.divider}`)
.getPosition()
.then(({ x, y }) => {
currentX = x;
currentY = y;
})
.end();
for (let i = 0; i < resizes.length; i++) {
const move = resizes[i];
const delta = expected[i];
command = resize(command, move.x, move.y)
.findByCssSelector(`.${css.divider}`)
.getPosition()
.then(({ x, y }) => {
if (typeof delta.x === 'function') {
assert.isTrue(delta.x(x), `Resize ${i} should pass x test.`);
}
else {
assert.closeTo(x, currentX + delta.x, ERROR_MARGIN, `Resize ${i} should move x by ${move.x}.`);
}
if (typeof delta.y === 'function') {
assert.isTrue(delta.y(y), `Resize ${i} should pass y test.`);
}
else {
assert.closeTo(y, currentY + delta.y, ERROR_MARGIN, `Resize ${i} should move y by ${move.y}.`);
}
currentX = x;
currentY = y;
})
.end();
}
return command;
}