I have just run a set of automated tests via the command line using Maven as my build tool and JUnit4 as my test execution framework. There was a report of two errors which were recorded in a text file as NoSuchElementException: no such element. I decided to run the same class from the IDE and received no errors.

Has anyone experienced this? If so, can someone please explain what might be the cause to make such an event occur.

Thanks in advance.

2 Answers 2


Three possibilities:

  1. The IDE inputs (e.g. arguments and environment variables) are not the same as the command line inputs. You can check that with print statements or logging.
  2. The libraries are not the same. I assume you know how to check this.
  3. You found a timing problem. To check this, first determine which element is erroring out, then try waiting before accessing that element.

I was plagued with a similar issue, but I think I have now solved it. The tests would invariably run perfectly in the IDE (Eclipse) but would usually (but not always) fail with the above error message when run from Jenkins.

The application under test is very slow and has some Javascript making AJAX calls on each page which don't help. The test was failing when checking that a certain piece of text was present on the page (e.g. "enter customer details"). Under the covers, I think it was executing assertCondition(ExpectedConditions.textToBePresentInElementValue(convertedSelector, text));

It seemed that if the test tried to put some data into a page element (or click on it) then Web Driver would wait for the page to complete loading, but if it was just checking that something was there (as per the above example) then it would wait 10 seconds (our local default wait time) before giving up. That caused the irregular failures on Jenkins.

The solution was to store (in a String) all the visible text on the page. I then searched the string for the required text and it worked OK.

Of course, given the intermittent nature of the fault, I can't be SURE I've fixed it! But I hope this helps.

  • You should probably be using waits; Selenium sees the page as loaded usually before the AJAX kicks off, so you should be telling it to wait for some indication that the AJAX has finished. See deanhume.com/Home/BlogPost/… Commented Apr 10, 2014 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.