gpt4 book ai didi

javascript - 使用 webdriverjs 等待页面完全加载

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:21:28 25 4
gpt4 key购买 nike

使用用于 javascript 的 selenium-webdriver 等待页面完全加载的最佳方法是什么?我注意到 this question非常相似,但我需要在 javascript 中实现。

var webdriver = require('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;

var driver = new webdriver.Builder()
.forBrowser('firefox')
.build();

driver.get('http://www.google.com');

// Wait for the page to fully load here...
// Something like this...
// driver.wait(...);

// Then do other stuff here

driver.quit();

最佳答案

我发现这可以满足我的需要。

driver.get('http://www.google.com');

driver.wait(function() {
return driver.executeScript('return document.readyState').then(function(readyState) {
return readyState === 'complete';
});
});

// Do stuff after page load here

关于javascript - 使用 webdriverjs 等待页面完全加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44318688/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com