Re: [selenium-users] org.openqa.selenium.WebDriverException: waiting for doc.body failed

1,245 views
Skip to first unread message

Mark Collin

unread,
Jan 15, 2013, 11:44:15 AM1/15/13
to seleniu...@googlegroups.com
Quick clarification, you are not doing unit testing you are doing functional acceptance testing.  Unit testing would be testing units of code, whereas functional acceptance testing is testing that the website functionality works as expected.

Which Firefox ESR?  17?

You would need to provide your scripts and show where they are failing along with the website you are testing to get and real help.

I would guess that the pages changes slightly, or you are using locators that are not quite up to the job.


On 15/01/2013 15:06, Apostolos Kitsopoulos wrote:
Hi everyone!

I have created 25 tests using Selenium IDE 1.9.0.
The tests are running in Linux OS and the browser is FirefoxESR.

After running the tests, I get the following error. The error appears randomly in every run. So, I may run them now and I get the error in 2 or 5 or 1 or whatever number of tests. It is so random that I cannot understand what the problem is. Rarely the run is perfect and no error appears!!
The error appears mostly (not always) after the log in to the application I'm testing.
This is my first experience in unit testing and I will appreciate any help. I'm really puzzled.

Please for your help.
Thanks a lot
~apostolos


15/01/2013 16:11:09 - ERROR: gr.pcs.wm.tests.ACLtest: org.openqa.selenium.WebDriverException: waiting for doc.body failed
Command duration or timeout: 13.18 seconds
Build info: version: '2.23.1', revision: '17143', time: '2012-06-08 18:59:28'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '2.6.39-200.34.1.el6uek.x86_64', java.version: '1.6.0_37'
Driver info: driver.version: RemoteWebDriver
Session ID: 63fbd652-616d-474f-b310-821492168f3a

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/TbwsxnQIZ0sJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mark Collin

unread,
Jan 17, 2013, 1:32:32 AM1/17/13
to seleniu...@googlegroups.com

That would imply that the JavaScript snippet “return AdfPage.PAGE.isSynchronizedWithServer()” is returning false after 20 seconds.

 

I would read that as you have an issue with server synchronisation and most likely a bug in the system somewhere.

 

From: seleniu...@googlegroups.com [mailto:seleniu...@googlegroups.com] On Behalf Of Apostolos Kitsopoulos
Sent: 16 January 2013 09:03
To: seleniu...@googlegroups.com
Subject: Re: [selenium-users] org.openqa.selenium.WebDriverException: waiting for doc.body failed

 

Mark thanks a lot for your prompt reply.
You are absolutely right about the definition of the unit testing. What I'm doing is functional acceptance testing, as you correctly mention.

The browser is Firefox ESR 10.0.8

The simplest test is just a log in - log out and close the browser. The error would appear 99% right after the line:
waitForPageToFinishRendering(driver, 20000L, "1");
which is actual right after the log in.


public class LogInLogOutTest extends JUnitWmTest {
    private Logger logger = Logger.getLogger(this.getClass().getName());

    @Test
    public void runTest() throws Exception {
        try {
            this.logInLogOut();
        } catch (Exception e) {
            logger.error(e);
            takeSnapshot("Error_" + this.getClass().getName());
            throw e;               
        }           
    }
   
    private void logInLogOut(){
        logger.info("Start [Test] of " + this.getClass().getName());
        driver.get(baseUrl);
       
        //Log in
        driver.findElement(By.id("it1::content")).clear();
        driver.findElement(By.id("it1::content")).sendKeys("user1");
        halfSleep(); // -> Thread.sleep(500L);
        driver.findElement(By.id("cb1")).click();
        waitForPageToFinishRendering(driver, 20000L, "1");
       
        //Log out
        driver.findElement(By.id("pt1:pSt1:pt_cl1")).click();
        logger.info("End [Test] of " + this.getClass().getName());
    }
}


and the method waitForPageToFinishRendering is actual doin this:

    public void waitForPageToFinishRendering(WebDriver oDriver,
                                             Long waitMilliseconds,
                                             String debugString) {
                                            
        ExpectedCondition e = new ExpectedCondition() {
            public Boolean apply(Object d) {

                JavascriptExecutor js = (JavascriptExecutor)d;
                Boolean isReady =
                    (Boolean)js.executeScript("return AdfPage.PAGE.isSynchronizedWithServer()");
                return isReady;
            }
        };
        logger.info("Timeout for " + waitMilliseconds + " milliseconds... (debug string: " + debugString + ").");
        WebDriverWait w = new WebDriverWait(oDriver, waitMilliseconds, 100L);
        w.until(e);
    }

Any suggestion is welcome!
Thanks in advance
~apostolos

To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/t2NV_mzJtbgJ.

Maxim Vorobev

unread,
Jan 17, 2013, 2:11:30 AM1/17/13
to selenium-users
ExpectedCondition e = new ExpectedCondition() {
public Boolean apply(Object d) {
try{

JavascriptExecutor js = (JavascriptExecutor)d;
Boolean isReady =
(Boolean)js.executeScript("return AdfPage.PAGE.isSynchronizedWithServer()");
return isReady;
}
};
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/t2NV_mzJtbgJ.

Maxim Vorobev

unread,
Jan 17, 2013, 2:15:12 AM1/17/13
to selenium-users
ExpectedCondition e = new ExpectedCondition() {
public Boolean apply(Object d) {
try{
JavascriptExecutor js = (JavascriptExecutor)d;
Boolean isReady =
(Boolean)js.executeScript("return AdfPage.PAGE.isSynchronizedWithServer()");
return isReady;
} catch (WebDriverException e) {
  //somthingwrongbutidontcare
  return false;
}
}
};

Apostolos Kitsopoulos

unread,
Jan 17, 2013, 2:22:51 AM1/17/13
to seleniu...@googlegroups.com
Mark and Maxim

many thanks for your reply!!
I'll try out the suggested try/catch solution and reply the results.

Best Regards,
~apostolos

Apostolos Kitsopoulos

unread,
Jan 17, 2013, 7:41:56 AM1/17/13
to seleniu...@googlegroups.com
Maxim the try / catch solution seems to work fine.
I'll continue testing...

Many thanks for your help!
~apostolos
Reply all
Reply to author
Forward
0 new messages