1

I'm developing tests with TestNG and Selenium WebDriver for some custom Alfresco modules being developed by our team.

After the page loading I need to wait for all AJAX requests to get necessary WebElement. I found this approach. I've figured out that Alfresco uses Dojo.

So i wrote a following method (timeout is yet to be added):

void waitForAJAX() {

if(javascriptExecutor == null) {
    throw new UnsupportedOperationException(webDriverType.toString() + " does not support javascript execution.");
}
boolean presentActiveConnections = true;
Integer numOfCon;
// Minor optimization. Getting rid of the repeaedly invocation of valueOf() in while.
Integer zeroInteger = Integer.valueOf(0);
while(presentActiveConnections) {
    numOfCon = (Integer)javascriptExecutor.executeScript("return selenium.browserbot.getCurrentWindow().dojo.io.XMLHTTPTransport.inFlight.length");
    if( numOfCon.equals(zeroInteger) ) {
        presentActiveConnections = false;
    }
}

}

But when i run my tests i get following error on invocation of this method from the test:

Failed: ReferenceError: dojo is not defined.

Should dojo variable be available from any javascript? I was unable to locate it too when i manually checked the page source.

Thanks in advance.

4

0 回答 0