No such element

I often get  “org.openqa.selenium.NoSuchElementException: no such element” when my script fails to find an element. I typically add only a few at a time and have output to help figure out where things went wrong but I was wondering why it doesn’t state what element can’t be found.


Add Comment
  • 3 Answer(s)

    hi richard

    i Have Captured a Screenshot to Make You Understand How to Find Error

    Please Let me Know If it works

    RE: No such element


    Vice Professor Answered on August 27, 2014.
    Add Comment

    Hi Richard,

    What you are looking at is the member functions of NoSuchElementException. You have to catch this exception and then abstract the information like so

     FirefoxDriver driver = new FirefoxDriver();
     Thread.sleep(3000); //just for fun
     WebElement element1 = driver.findElement("thh887"));
     catch(NoSuchElementException exp)
     System.out.println("Additional information is " + exp.getAdditionalInformation());
     System.out.println("Localized information is " + exp.getLocalizedMessage());
     System.out.println("Support URL information is " + exp.getSupportUrl());
     System.out.println("Cause information is " + exp.getCause());

    You are specifically interested in the information displayed by this exp.getLocalizedMessage();
    Translated to class member it is NoSuchElementException .getLocalizedMessage();

    so you have to catch the exception and find what this method has to say.


    Professor Answered on August 27, 2014.
    Add Comment

    when you get no such element exception error . You can check the exception error java(24.89)
    so the error is at line 24 of the code.  Now from this info you can find which element location

    hope this will help you

    Doctor Answered on September 1, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.