我在我的函数文件中创建了一个函数,所以我可以在我的脚本中调用它。这个函数与我的其他函数的不同之处在于,它是常规函数中的ClientFunction。在我的脚本文件中调用它不会做任何事情。
我已经创建了我的函数,并导入和导出了我需要的所有内容。我在脚本中调用函数的方式与调用其他函数的方式相同。这些其他函数运行良好。
从我的函数文件'globalFunctions.js‘
import {ClientFunction} from 'testcafe';
export async function scroll(){
const scroll = ClientFunction(function() {
window.scrollBy(0,1000)
});
return(scroll);
};从我的脚本文件
import * as globalFunctions from './global_functions.js';
globalFunctions.scroll(t)我正在调用的其他函数运行良好
globalFunctions.namegenerator(t)期望值:
当我调用scroll()函数时,页面应该滚动到页面底部。
实际:
页面不会向下滚动,代码会转到下一行,然后脚本就不会说我的对象没有找到。
发布于 2019-06-05 06:30:47
通过将我的函数更改为:
export const scroll = ClientFunction(function() {
return window.scrollBy(0,1000)
});并在我的脚本中通过以下方式调用:
await globalFunctions.scroll()https://stackoverflow.com/questions/56452001
复制相似问题