2012-03-08 59 views
2

我正在使用Selenium来驱动使用Dojo的网站。由于网站的Dojo网格使用延迟加载,因此我的测试框架很难知道网格是否完成加载。但是,Selenium确实让你注入Javascript。有没有方法可以轮询DOM,或直接使用js来查找网格是否已完成加载?如何确定dojo网格是否已完成加载?

回答

0

dojox.grid.DataGrid有获取_onFetchComplete设置一个内部标志,所以你可以尝试

var grid = ... 
if (grid._isLoaded) { 
    ... 
} 
0

我发现这个问题,因为我一直在寻找同样的事情。我能得到的最接近的结果是等待Dojo的加载消息消失(如果网格加载速度很快,很难看清楚)。这里是我现在使用的:

/** Required imports **/ 
import org.openqa.selenium.support.ui.ExpectedConditions; 
import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.firefox.FirefoxDriver; 
import org.openqa.selenium.By; 

/** Code snippet **/ 
WebDriver driver = new FirefoxDriver(); 
WebDriverWait wait = new WebDriverWait(driver, /* Max wait time */ 30); 
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".dojoxGridLoading")); 

这让我非常接近。

0

这是使用非内部事件 “onStyleRow” 的解决方案:

// Declare myGridLoaded 
var myGridLoaded = false; 
... 
... 
// Connect onStyleRow: 
dojo.connect(grid, "onStyleRow", grid, function(row) { 
    if(!myGridLoaded) { 
     doYourStuff(); 
     // Make sure it runs only once: 
     myGridLoaded = true; 
    } 
}); 
// Now set your store and the handler will run only once 
// when the first row is styled - if any: 
grid.setStore(store); 
相关问题