在 Selenium IDE 扩展中使用 setTimeout
我正在尝试在为 Selenium IDE 制作的扩展中使用 JavaScript 的 setTimeout 。
简而言之,我已经进行了扩展,以获取用户名和密码来登录页面,而不必在每次测试时使用一些命令,使用我的自定义命令可以节省大量时间。
显然需要等待页面加载,所以我添加了一个 setTimeout 来调用一个函数,该函数将不断检查页面是否准备好。
然而 setTimeout 似乎只运行一次。
我想我的脚本可能有问题,我只是从 w3schools 复制了一些脚本,但也无法工作,所以尝试了下面这个简单的脚本,它肯定应该工作,但我只得到“1”的日志输出。
var i=0;
function loopThrough(){
i=i+1;
LOG.info(i);
setTimeout("loopThrough()", 2500);
}
loopThrough();
I'm trying to use JavaScript's setTimeout in an extension I've made for Selenium IDE.
In short I have made the extension to take a username and password to login to a page, rather than having to use a few commands on every test I make, it'd save a lot of time using my custom command.
So obviously In need to wait for the page to load, so I have added a setTimeout which calls a function that will keep checking if the page is ready yet.
setTimeout only seems to run the once however.
Thinking I may have something wrong with my script I just copied some off w3schools and that fails to work either, so tried this simple one below, which surely should work, but I only get a log output of '1'.
var i=0;
function loopThrough(){
i=i+1;
LOG.info(i);
setTimeout("loopThrough()", 2500);
}
loopThrough();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论