views:

311

answers:

1

Hi, I have a problem: when I try to run a JUnit TestCase through Eclipse, in debug mode (using Debug as JUnit Test), it runs perfectly well (I step over each statement), but if I run it normally, not in debug mode (using Run as JUnit Test), the TestCase runs until some point and then fails when trying to find some html element in the page using xpath, i.e. div, td. I check to see if the element is present in the page using Xpath Checker and it's present.

What could be the possible reason for this? Did anyone confront something like this?

+1  A: 

This sounds like the test is running faster than the application under test. You need to make sure that you use waitForPageToLoad wherever a page load occurs. Also, if your application uses AJAX at all you may have to use something like waitForCondition to ensure that the element exists before attempting to access it.

In future, Selenium may implicitly wait for elements to exist rather than immediately throwing the 'element not found' error but for the time being these waits must be explicit.

Dave Hunt
Yes, you are right. My application uses AJAX and I had to wait for the entire/part of page to reload.
ratzusca